Uptime Command
Uptime Command
Linux System Administrators that are used in their daily life. This is not a complete but it’s a compact list
of commands to refer when needed. Let us start one by one how we can use those commands with
examples.
30 Useful Linux System Administration Commands
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.
# uptime
tecmint
4. Who Command
who command simply return user name, date, time and host information. who command is similar to w
command. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the
different between who and w commands.
# who
tecmint
6. ls Command
ls command display list of files in human readable format.
# ls -l
total 114
dr-xr-xr-x. 2 root root 4096 Sep 18 08:46 bin
dr-xr-xr-x. 5 root root 1024 Sep 8 15:49 boot
Sort file as per last modified time.
# ls -ltr
total 40
-rw-r--r--. 1 root root 6546 Sep 17 18:42 install.log.syslog
-rw-r--r--. 1 root root 22435 Sep 17 18:45 install.log
-rw-------. 1 root root 1003 Sep 17 18:45 anaconda-ks.cfg
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.
# crontab -l
00 10 * * * /bin/ls >/ls.txt
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.
# crontab -e
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.
# less install.log
Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID
c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch
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.
# more install.log
Installing setup-2.8.14-10.el6.noarch
warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID
c105b9de: NOKEY
Installing filesystem-2.4.30-2.1.el6.i686
Installing ca-certificates-2010.63-3.el6.noarch
Installing xml-common-0.6.3-32.el6.noarch
Installing tzdata-2010l-1.el6.noarch
Installing iso-codes-3.16-2.el6.noarch
--More--(10%)
10. CP Command
Copy file from source to destination preserving same mode.
# cp -p fileA fileB
You will be prompted before overwrite to file.
# cp -i fileA fileB
11. MV Command
Rename fileA to fileB. -i options prompt before overwrite. Ask for confirmation if exist already.
# mv -i fileA fileB
12. Cat Command
cat command used to view multiple file at the same time.
# cat fileA fileB
You combine more and less command with cat command to view file contain if that doesn’t fit in single
screen / page.
# cat install.log | less
/root
15. Sort command
Sorting lines of text files in ascending order. with -r options will sort in descending order.
#sort fileA.txt
#sort -r fileA.txt
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 -R option. Press ‘:q‘ to quit from vi window.
# vi -R /etc/shadows
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.
# ssh [email protected]
To check the version of ssh use option -V (uppercase) shows version of ssh.
# ssh -V
# sftp 192.168.50.2
Putting multiple files in remote host with mput similarly we can do mget to download multiple files from
remote host.
# ftp > mput *.txt
tecmint:x:500:500::/home/tecmint:/bin/bash
24. Find Command
Find command used to search files, strings and directories. The below example of find command search
tecmint word in ‘/‘ partition and return the output.
# find / -name tecmint
/var/spool/mail/tecmint
/home/tecmint
/root/home/tecmint
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.
# lsof -u tecmint
# kill- 9 7508
29. rm command
rm command used to remove or delete a file without prompting for confirmation.
# rm filename
Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file
forcefully without confirmation.
# rm -i test.txt