Most Important UNIX/Linux Commands with Explanations

UNIX/Linux

In this Tutorial, I listed the most important UNIX/Linux Commands and I described with Explanations of Command in Detail.

Linux File Commands

1. ls = Directory listing
2. ls -al = It will list with hidden files
3. ls -lt = Sorting by time modification
4. cd tharun = Change directory to tharun
5. cd = Change to the home directory
6. pwd = Show current working directory
7. mkdir linuxstories = Creating a directory linuxstories
8. cat > file = It will places the standard input into the file
9. more file = It will Output the contents of the file
10. head file = it will show the Output of the first 10 lines of the file
11. tail file = it will show the Output of the last 10 lines of the file
12. tail -f file = it will show the Output of the file as it grows, starting with the last 10 lines
13. touch file = Create or update file

File Commands

14. rm file = Deleting the file
15. rm -r Jami = Deleting the directory name called Jami
16. rm -f Poo = Force to remove the file name called Poo
17. rm -rf ts = Force to remove the directory ts
18. cp file1 file2 = Copy the contents of file1 to file2
19. cp -r dir1 dir2 = Copy dir1 to dir2;create dir2 if not present
20. mv file1 file2 = Rename or move file1 to file2,if file2 is an existing directory
21. ln -s file = link Create a symbolic link to file

Process management

1. ps = It will display the current working processes
2. top = Display all running process
3. kill pid = Kill the process with given pid replace pid with ur pid number Example (kill 1234)
4. killall sshd = sshd Kill all the process named sshd
5. pkill proc = Will kill all processes matching the proc
6. bg = List a stopped or background jobs and resume a stopped job in the background
7. fg = It will bring the most recent job to the foreground
8. fg n = It will bring job n to the foreground

File permission

There are three things you can do to a file that is read write and execute. which can
be found separately for user, group, others.

1. chmod octal file = it is to Change the permission of a file
• 4-read(r)
• 2-write(w)
• 1-execute(x)

Example : chmod 755 tharun (rwx-rx-rx)

Here tharun directory has 755 means (7 is for users 5 is group and another is 5 is for others)

Searching

1. grep ssh = file Search for ssh in file
2. grep -r ssh dir = Search recursively for ssh in dir
3. command | grep Linux = Search Linux in the output of a command
4. locate file = Find all instances of file
5. find . -name filename = it will search in the current directory (represented by a period) and below it, for files and directories with names starting with a filename
6. pgrep pattern Searches for all the named processes, that matches with the pattern and, by default, returns their ID

System Info

1. date = It will Show the current date and time
2. cal = It will Show this month’s calendar
3. uptime = It Shows current uptime
4. w = This will Display who is online
5. whoami = It will show Who you are logged in as

Unix/Linux Command Reference

6. finger user = It will display information about the user
7. uname -a = It will show kernel information
8. cat /proc/cpuinfo = It will show the Cpu information
9. cat proc/meminfo = It will show the Memory information
10. man command = it will show the manual for command
11. df = It will Show the disk usage
12. du = It Show directory space usage
13. free = It will Show memory and swap usage
14. whereis app = It Shows possible locations of app
15. which app = It Shows which applications will be run by default

Compression

1. tar cf file.tar file = It will Create a tar named file.tar containing the file
2. tar xf file.tar = It will Extract the files from file.tar
3. tar czf file.tar.gz files = It will Create a tar with Gzip compression
4. tar xzf file.tar.gz = It will Extract a tar using Gzip
5. tar cjf file.tar.bz2 = It will Create a tar with Bzip2 compression
6. tar xjf file.tar.bz2 = It will Extract a tar using Bzip2
7. gzip file = It will Compresses file and renames it to file.gz
8. gzip -d file.gz = It will Decompress file.gz back to file

Network

1. ping hostname = It will ping the host and output results
2. whois domain = It will Get whois information for domains
3. dig domain = It will Get DNS information for the domain
4. dig -x hostname = It will show the Reverse lookup host
5. wget file = It will Download a file
6. wget -c file = It will Continue a stopped download

Shortcuts

1. ctrl+c = Its Halt the current command
2. ctrl+z = It will Stops the current command, resume with fg in the foreground or bg in the background
3. ctrl+d = It will Logout the current session, similar to exit
4. ctrl+w = This will Erases one word in the current line
5. ctrl+u = This will Erases the whole line
6. ctrl+r = It will Type to bring up a recent command
7. !! = It will Repeat the last command
8. exit = This will Logout the current session

Leave a Reply

Your email address will not be published. Required fields are marked *