Thursday 25 February 2016




10 Most Frequently Used Linux/UNIX Commands


Hi everyone, today I’m posting a list of most frequently used linux commands that I use.

1.ls command

Display filesize in human readable format (e.g. KB, MB etc.,)
$ ls -lh
-rw-r----- 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz
Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr
$ ls -ltr


2.sort command 
Sort a file in ascending order
$ sort file.txt
Sort a file in descending order
$ sort -r file.txt

3.grep command 
Search for a given string in a file (case in-sensitive search).



$ grep -i "the" example_file
Print the matched line, along with the 5 lines after it.
$ grep -A 5 -i "example" example_text
Search for a given string in all files recursively
$ grep -r "Sam" *

4. find command

Find files using file-name ( case in-sensitve find)
# find -iname "HelloWorld.c"
Execute commands on files found by the find command

$ find -iname "MyCProgram.c" -exec md5sum {} \;

5.ssh command
Login to remote host
ssh -l ramu remotehost.example.com
Debug ssh client
ssh -v -l ramu remotehost.example.com

6.vim command
Go to the 100th line of file
$ vim +100 filename.txt
Go to the first match of the specified
$ vim +/search-term my_file.txt
Open the file in read only mode.
$ vim -R /etc/oratab


7. export command
To view oracle related environment variables.
$ export | grep ORACLE
declare -x ORACLE_BASE="/u01/app/oracle"
declare -x ORACLE_HOME="/u01/app/oracle/product/10.2.0"
declare -x ORACLE_SID="med"
declare -x ORACLE_TERM="xterm"


8.gzip command
To create a *.gz compressed file:
$ gzip test.txt
To uncompress a *.gz file:
$ gzip -d test.txt.gz
Display compression ratio of the compressed file using gzip -l
$ gzip -l *.gz
         compressed        uncompressed  ratio uncompressed_name
              23709               97975  75.8% asp-patch-rpms.txt

9.shutdown command examples
Shutdown the system and turn the power off immediately.
# shutdown -h now
Shutdown the system after 10 minutes.
# shutdown -h +10
Reboot the system using shutdown command.
# shutdown -r now

10.ftp command
To connect to a remote server and download multiple files.
$ ftp IP/hostname
ftp> mget *.html
To view the file names located on the remote server before downloading, mls ftp command as shown below.
ftp> mls *.html -
/test/hello.html
/test/employees.html
/test/tools.html
/test/sampletest.html
/test/users.html








No comments:

Post a Comment