See more...

Top 10 Most Commonly Used Linux Terminal Commands

Here is a list of commonly used Linux commands as a headstart for the beginner or as a reference for everyone else. It has been a while that we published a series of how-to’s in Linux scripting. Very useful for people who passed beginner-status. This post is not a how-to, but a basic list of examples for commonly used Linux commands.

Commonly Used Linux Commands

Linux Commands

Create a New tar Archive

$ tar cvf archive_name.tar dirname/

Extract from an Existing tar Archive

$ tar xvf archive_name.tar

View an Existing tar Archive

$ tar tvf archive_name.tar

Find Command Examples

Find Files Using file-name ( case in-sensitve find)

# find -iname "MyCProgram.c"

Execute Commands on Files Found by the Find Command

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

Find all Empty Files in Home Directory

# find ~ -empty

SSH Command Examples

Login to Remote Host

ssh -l johndoe

Debug SSH Client

ssh -v -l johndoe

Sort Command Examples

Sort a File in Ascending Order

$ sort places.txt

Sort a file in descending order

$ sort -r places.txt

Sort Passwd File by 3rd Field

$ sort -t: -k 3n /etc/passwd | more

Export Command Examples

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"

To Export an Environment Variable

$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0

GZIP Command Examples

To Create a *.gz Compressed File

$ gzip testing.txt

To Uncompress a *.gz File

$ gzip -d testing.txt.gz

BZIP2 Command Examples

To Create a *.bz2 Compressed File

$ bzip2 test.txt

To Uncompress a *.bz2 File

bzip2 -d test.txt.bz2

Unzip Command Examples

To Extract a *.zip Compressed File

$ unzip

FTP Command Examples

Both ftp and secure ftp (sftp) have similar commands. To connect to a remote server and download multiple files, you can do the following.

$ ftp IP/hostname
ftp> mget *

To view the file names located on the remote server before downloading, mls ftp command as shown below.

ftp> mls *.html -

SED Command Examples

When you copy a DOS file to Unix, you could find \r\n in the end of each line. This example converts the DOS file format to Unix file format using sed command.

$sed 's/.$//' filename

Print File Content in Reverse Order

$ sed -n '1!G;h;$p' jaxov.txt

Add Line Number for all Non-empty-lines in a File

$ sed '/./=' jaxov.txt | sed 'N; s/\n/ /'

Did We Miss Any Commonly Used Linux Commands?

Did we miss your favorite Linux commands? Let us know, so we can make a second list of commonly used Linux commands.

Contact Us for News Tips, Corrections and Feedback

Related posts

Leave a message...