30 Useful Linux Commands for System Administrators
1. Uptime Command
In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals.
Check Uptime Version
Uptime command don’t have other options other than uptime and version. It gives information only inhours:mins if it less than 1 day.
2. W Command
It will displays users currently logged in and their process along-with shows load averages. also shows the login name, tty name, remote host, login time, idle time, JCPU, PCPU, command and processes.
Available options
- -h : displays no header entries.
- -s : without JCPU and PCPU.
- -f : Removes from field.
- -V : (upper letter) – Shows versions.
3. Users Command
Users command displays currently logged in users. This command don’t have other parameters other than help and version.
4. Who Command
who command simply return user name, date, time and host information. who command is similar to wcommand. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the different between who and w commands.
Who command Options
- -b : Displays last system reboot date and time.
- -r : Shows current runlet.
- -a, –all : Displays all information in cumulatively.
5. Whoami Command
whoami command print the name of current user. You can also use “who am i” command to display the current user. If you are logged in as a root using sudo command “whoami” command return root as current user. Use “who am i” command if you want to know the exact user logged in.
6. ls Command
ls command display list of files in human readable format.
Sort file as per last modified time.
For more examples of ls command, please check out our article on 15 Basic ‘ls’ Command Examples in Linux.
7. Crontab Command
List schedule jobs for current user with crontab command and -l option.
Edit your crontab with -e option. In the below example will open schedule jobs in VI editor. Make a necessary changes and quit pressing :wq keys which saves the setting automatically.
For more examples of Linux Cron Command, please read our earlier article on 11 Cron Scheduling Task Examples in Linux.
8. Less Command
less command allows quickly view file. You can page up and down. Press ‘q‘ to quit from less window.
9. More Command
more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.
10. CP Command
Copy file from source to destination preserving same mode.
You will be prompted before overwrite to file.
11. MV Command
Rename fileA to fileB. -i options prompt before overwrite. Ask for confirmation if exist already.
12. Cat Command
cat command used to view multiple file at the same time.
You combine more and less command with cat command to view file contain if that doesn’t fit in single screen / page.
For more examples of Linux cat command read our article on 13 Basic Cat Command Examples in Linux.
13. Cd command (change directory)
with cd command (change directory) it will goes to fileA directory.
14. pwd command (print working directory)
pwd command return with present working directory.
15. Sort command
Sorting lines of text files in ascending order. with -r options will sort in descending order.
16. VI Command
Vi is a most popular text editor available most of the UNIX-like OS. Below examples open file in read only with -Roption. Press ‘:q‘ to quit from vi window.
17. SSH Command (Secure Shell)
SSH command is used to login into remote host. For example the below ssh command will connect to remote host (192.168.50.2) using user as narad.
To check the version of ssh use option -V (uppercase) shows version of ssh.
18. Ftp or sftp Command
ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).
Putting multiple files in remote host with mput similarly we can do mget to download multiple files from remote host.
19. Service Command
Service command call script located at /etc/init.d/ directory and execute the script. There are two ways to start the any service. For example we start the service called httpd with service command.
20. Free command
Free command shows free, total and swap memory information in bytes.
Free with -t options shows total memory used and available to use in bytes.
21. Top Command
top command displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Use top command with ‘u‘ option this will display specific User process details as shown below. Press ‘O‘ (uppercase letter) to sort as per desired by you. Press ‘q‘ to quit from top screen.
For more about top command we’ve already compiled a list of 12 TOP Command Examples in Linux.
22. Tar Command
tar command is used to compress files and folders in Linux. For example the below command will create a archive for /home directory with file name as archive-name.tar.
To extract tar archive file use the option as follows.
To understand more about tar command we’ve created a complete how-to guide on tar command at 18 Tar Command Examples in Linux.
23. Grep Command
grep search for a given string in a file. Only tecmint user displays from /etc/passwd file. we can use -i option for ignoring case sensitive.
24. Find Command
Find command used to search files, strings and directories. The below example of find command searchtecmint word in ‘/‘ partition and return the output.
For complete guide on Linux find command examples fount at 35 Practical Examples of Linux Find Command.
25. lsof Command
lsof mean List of all open files. Below lsof command list of all opened files by user tecmint.
For more lsof command examples visit 10 lsof Command Examples in Linux.
26. last command
With last command we can watch user’s activity in the system. This command can execute normal user also. It will display complete user’s info like terminal, time, date, system reboot or boot and kernel version. Useful command to troubleshoot.
You can use last with username to know for specific user’s activity as shown below.
27. ps command
ps command displays about processes running in the system. Below example show init process only.
28. kill command
Use kill command to terminate process. First find process id with ps command as shown below and kill process with kill -9 command.
29. rm command
rm command used to remove or delete a file without prompting for confirmation.
Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file forcefully without confirmation.
30. mkdir command example.
mkdir command is used to create directories under Linux.
This is a handy day to day useable basic commands in Linux / Unix-like operating system. Kindly share through our comment box if we missed out.
No comments:
Post a Comment