Top 120 Commands for Linux Administrators

 

In this post i have described about the most used top 120 linux commands. It is more recommended for linux administrators.

 

 

1. Command to Open pdf file from Command Mode

#acroread Bash-Beginners-Guide.pdf
2. Command to Open pdf file from Command Mode

#evince Bash-Beginners-Guide.pdf

3.Command used to open Web Page from Command mode

#links

4.Command used to get in to tutorial in VIM editor

#vimtutor

5.Command used to find Spelling mistake in a file linux admin commands, unix admin commands, linux administrator commands, unix administrator

#aspell list < newfile

6.Command used to change between  Virtual terminal

chvt 1
chvt 1 2 3 .. 7

7.Command used to view a file content in reverse order

#tac

8.Command used to display an image from command mode

#display test.png

9.Command to convert pdf to any format

#convert bash.pdf pash.jpg

10.Redirecting Output to another pesto terminal

#cal > /dev/tty3

11.Delete the first line from the file file.txt

#sed -i 1d file.txt
12.Delete the fifth ,Sixth and seventh line of file file.txt

# sed -i 5,7d file.txt

13.Way to empty a file

#cat /dev/null > test.txt
#echo  > test.txt

14.Command to show the number of lines, words and letters in a file

#.wc if.sh
23  449 3535 if.sh

15.command to change man page to txt file.

#man set | col -b > set.txt

16.Command to change man page to doc file.
#man set | col -b > set.doc

17.Command to change man page to pdf file.
#man -t pwd | ps2pdf – pwd.pdf

18.Command to take screen shot from terminal

#import a.png

19.Commands used to show routing table in linux system

#netstat -r
20.Commands used to show routing table in linux system

#route

#route -n

21.Commands used to show routing table in linux system

#ip route list

22.Command used to create shortcuts for commands

#alias
#alias lll=’ls -1tr | tail -1′
22.Command used to remove all alias commands.

#unalias

23.Command will remove only alias of lll.
#unalias lll

24.Command will remove all alias
#unalias -a

25.Same as like of history command

#fc -l -5

26.Command will display in what all the groups the user is present

#groups
27.Command used to save every printed in the screen.

#script  aa.txt

28. Command used to add append and display content of a file

#cat hello.txt

29. Command used to add append and display content of a file

#ul  hello.txt

30.Command used to add append and display content of a file

#colcrt hello.txt
31. Command used to add append and display content of a file

#nroff hello.txt

32.Command used to display uid,gid of the user

#id

33.Command used to display only group name the user belongs to.

#id -ng rajm

34.Command used to display group ID of the user belongs to.

#id -g rajm

35.Command used to change tab to space.

#expand

36. Command used to convert all tab in file a to one space

#expand -1 a
37. Command used to change space to tab

#unexpand

38. History entry is temporally stopped

#set +o history

39. To start again after temporally stopped.

#set -o history

40. Command to display the boot up message of the machine.

#dmesg

41. Command used to remove all the empty directory recursively in the present working directory.

#cleanlinks

42. Command to view permission of the file or folder in order

#namei

43. Command to view permission of /etc , squid and squid.conf individually

#namei -m /etc/squid/squid.conf
44. Command to view whether it is a file or folder in order.

#namei -x /etc/squid/squid.conf

45. Command to export a variable in a Shell

#export raj=rajkumar
#env | grep raj
raj=rajkumar

46. Command to print the list of names exported
#export -p

47. Command used to display where the executable file is stored. basically its in /bin or /sbin

#which
#which iptables
/sbin/iptables

48. Command to open an doc file from command prompt

#gnome-open raj.doc

49. Command to view content of an tar ball

#zcat pkg-config-0.20.tar.gz

50. Command used to clear the terminal Screen.

#clear

51. Command read and execute command from file and execute it in the prompt.

#source

#cat >> ~/.bashrc
hi(){ ls -l }
#source ~/.bashrc

52.Command to change the time stamp of a file. It’s in the format of (YYMMDDhhmm[.ss])

#touch -t 201107132224.30 *.sql

53. Command used to print sequence of number from 1 – 25.

#seq 1 25

54. Command displays user’s Login, Home directory, IP,shell and logged in pts & idle time

#finger rajm
55. Command to displays all  Logged in users with their logged in terminals, from IP and idle time.

#finger

56. Command used to tell what type of file is it.

#file a.txt

57. Command used to list all UUID(Universally Unique Identifier library).

#blkid

58. Inform the OS of partition table changes

#partprobe

59. Find file by name

#locate

60. Displays IP address of the system from /etc/hosts file.

#hostname -i

61. Displays domain name of the system from /etc/hosts file.

#hostname -d

62. Mount all file systems (of the given types) mentioned in fstab.

#mount -a

63. Adjust tunable file system parameters on ext2/ext3 filesystems

#tune2fs

64. Add  an  ext3  journal  to the filesystem.

#tuen2fs -j

65. Build a Linux file system in ext3 format

#mkfs -t ext3 /dev/hda1
66. Build a Linux file system in ext2 format

#mkfs -t ext2 /dev/hda2

67. Creating a ext3 file system

#mkfs.ext /dev/sdb1

68. Creating a ext2 file system

#mkfs.ext2 /dev/sdb2

69. Command to find folder size

#du -sh

70. Command to find mounted partition with file system type.

#mount

71. To find whether a port is opened or not

#nc -z google.com 80

72. Command to find swap partition

swapon -s

73. Print the word rajkumar until its been killed

#yes rajkumar

74.list contents of directories in a tree-like format and it also displays number of files and directories in the folder.

#tree /home/rajm

75. Prints name of current/working directory.

#pwd
76.Report current working directory of a process

#pwdx pids

77. Used to determine wireless is enabled or not&configure a wireless network interface.

#iwconfig

78. Command used to bring up the eth0 interface down

#ifconfig eth0 down

79. Command used to bring up the eth0 interface up

#ifconfig eth0 up

80.Command used to query and set the hardware clock (RTC)

#hwclock
#hwclock –set –date “27 Sep 2011 23:01″

81. Command used to print or set the system date and time

#date
#date -s ” 24 JUL 2011 00:33:09″

82. Command used to change the time zone(“Asia/Calcutta”) information.If applied it also do changes in the configuration file(/etc/sysconfig/clock).

#timeconfig

83. Uptime command gives output of current time, how long the system has been running,how many users are currently logged on, and the system load averages for the past 1,5,15 min.

#uptime

84.Displays the exact last reboot Date & Time.

#who -b

85. Display current username(effective id – euid)

#whoami

85. Display parent username

#who am i

86. To view the time stamp of current time

#date +%s

87. To check the time stamp with current date & time

#date –d @1321266648 ; date

88. To close a terminal

skill -KILL /pts/20

89.It will tell how long the time taken to run the command.It can also be used in script

#time ls

90.It will display only hosts.deny. Used to display only last path filename.

#basename /etc/hosts.deny

91. Used to show the number of available semaphores in the system.

#ipcs -s

92.Show’s all the environment variable present in the system

#env

93. Show’s all the environment variable present in the system

#printenv

94. Print all the declared variables present in the system

#set

95. Print all the declared variables present in the system

#declare
96. Print all the declared variables present in the system

#typeset

97. Command to install a package in Ubuntu

#dpkg -i <package-name>

98. Command to install a package in Ubuntu

#apt-get install <package-name>
#apt-get install php-mysql

99.Command to remove a package in Ubuntu

#apt-get remove <package-name>

100.  Command to display the label of the partition /dev/sda1.

#e2label /dev/sda1

boot
101. Command to assign label for the partition /dev/sda2

#e2label /dev/sda2 /home

102. List permission, accessed, modified, changed, inode, size, UID, GID, Owner, full path and even type of a FILE.

#stat /etc/passwd

103. Command to open “Menu Layout” (or)Right Click Application “Edit Menu”

#alacarte

104. Command to shutdown the system

#poweroff

105.Command to shutdown the system
#init 0

106. Command to shutdown the system
#shutdown -h now

107. Visual shell for Unix-like systems.Make Commander

#mc

108. Displays all the command available in the Linux Box

#compgen -c

109.Register Redhat updates via Command line.

#rhn_register

110. Command to assign password like “passwd command”

#chpasswd

111. Used to create /etc/shadow file when it is deleted. pwconv uses /etc/passwd file to create /etc/shadow file

#pwconv

112. Reports the most recent Login of all users or of a given user

#lastlog

113. Command to create panel if the panel is not present

#gnome-panel

114. To kill gnome-panel if present

#killall gnome-panel

115. Command to find all opened ports in running linux machine

#netstat -ntpl

116. Command to find all opened ports in running linux machine

#lsof -i

117. TO list all chkconfig list

#chkconfig –list
118.find file based on size greater than 1kb

#find . -size +1k

119.find file based on size lesser than 1kb
#find . -size -1k

120. To change the history size

#HISTSIZE=450