0% found this document useful (0 votes)
45 views

Linux Commands

The document provides an overview of 81 important Linux commands that every Linux administrator should learn. It begins with background on the author and their experience. It then provides 3 sentence summaries of the cat, cd, and ls commands, highlighting their main purposes and usage. Examples are given for each command to illustrate their options and functionality.

Uploaded by

Subrata Ray
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Linux Commands

The document provides an overview of 81 important Linux commands that every Linux administrator should learn. It begins with background on the author and their experience. It then provides 3 sentence summaries of the cat, cd, and ls commands, highlighting their main purposes and usage. Examples are given for each command to illustrate their options and functionality.

Uploaded by

Subrata Ray
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

81 Linux Commands – You must learn

Every Linux administrator should learn these commands

Prepared for:
Public

Prepared by:
Ankam Ravi Kumar

Follow Me on Social Networking Sites

Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube

Reach me over Email: [email protected] or [email protected]

If you think this document helped a lot Donate a dollar as complementary


81 Linux Commands – You must Learn https://www.server-computer.com

Table of Contents
1. About Author .................................................................................................................................................................. 4
2. cat - command to see file content .................................................................................................................................. 5
3. cd – Change directory path ............................................................................................................................................. 6
4. ls command – listing files and directories ....................................................................................................................... 8

Table of Contents  2
If you find any corrections please contact [email protected]
Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

How to Use this Guide

Marked as key points, important points and examination points to remember

Table of Contents  3
If you find any corrections please contact [email protected]
Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

1. About Author

Ankam Ravi Kumar has more than 10+ years of experience in Information Technology
Operations and production support streams. He served more than 5 companies in his career and
still continuing.

We provide server and data center related services from purchasing of underlying hardware to
provisioning the applications.

Solid industry experience in Infrastructure Management/Customer Support/Operations and


Training Domains. I love to help people by sharing my knowledge and skills. I always believe
“Power is gained by Sharing Knowledge not hoarding it”.

 Operating System Management Such has Linux Different Flavors, Red hat, Fedora,
Ubuntu, AIX, Solaris and Windows
 Enterprise Server Management
 Installing and configuring Blade Servers
 Core Storage Management Dell-EMC, IBM and NetApp
 Database Management MSSQL, POSTGRESQL, MariaDB and MySQL
 Process Management ITIL
 Virtualization management RHEV, vSphere, VMware, KVM, Hyper-V and XEN
 Backup and Recovery Management NetVault, Commvault and Symantec Backup Exec
 Application Server Management and Storage Cluster Management
 Data Center Management and Hosting Solutions
 Programming Languages such as PHP and HTML
 Scripting Languages Shell, Perl and Python
 Cloud administration AWS, Azure and GCP

Specialized in managing and building the Teams for IT services delivery and Service Support,
Training and Operations in both smaller and larger companies. Rich experience and strong
exposure in IT Infrastructure & Data Center Management.

Implementation of monitoring solutions for Enterprise, Using Tools Nagios, NagiosXI, Cacti,
Solarwinds and LogicMonitor.

81 Linux Commands by www.server-computer.com – Most useful Linux commands  4

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

2. cat - command to see file content

Concatenate files and print on the standard output. Cat command used to see the content
of text files. Cat is a core utility, which comes along with Operating System installation no need
to install separately.

Syntax: cat <Options> <File Name>

Without any options cat can show the content of text file, example shown above screenshot.

-b, --number-nonblank: number nonempty output lines, overrides –n

Using –b option cat command will show the content with numbered lines, excluding blank
lines.

-E, --show-ends: display $ at end of each line

Option capital E will add $ (dollar sign) to end of the line including empty lines
81 Linux Commands by www.server-computer.com – Most useful Linux commands  5

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

-n, --number: number all output lines

Add numbers to all the lines including empty lines using option –n cat command

Current version 8.22. All above options will work properly as shown in examples. Please check
if version change options may change.

There are many options cat command has however above are the options most useful.

3. cd – Change directory path


Change the current directory to dir. The variable HOME is the default dir. By default when you
type cd without options, it will go back to HOME path.

Syntax: cd <Options> <DIRPATH>

81 Linux Commands by www.server-computer.com – Most useful Linux commands  6

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

Before jumping into the cd command and its options, you have to know about absolute path
and relative path.

1. Absolute path or Full path points to the location exactly regardless of current directory.
In simple terms absolute paths always start with (/) slash
2. Relative path or shortcut path. Relative path starts from some given working directory,
avoiding the need to provide the full path.
Example: I am in /var directory if I want to change path to /var/log/ no need
to provide full path just cd log/ do the job.

(Tilde)~ = $HOME or user home directory path, when you type cd ~ wherever your jump back
to user home path

In every directory path there are two hidden directories will be available which are. (Dot) and..
(Dot dot).
Single dot means current directory
Two dots means its parent directory

81 Linux Commands by www.server-computer.com – Most useful Linux commands  7

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

If you have symbolic links, you want to change to its original path not symbolic links then use –
P along with cd command

cd - You will go back to previous directory path. An argument of - is equivalent to


$OLDPWD

That is about cd command

4. ls command – listing files and directories


ls command is used to list information about the FILEs (the current directory by default). Sort
entries alphabetically if none of -cftuvSUX nor –sort is specified

Syntax: ls [options] arguments

Listing current directory content - You can list out all files and directories in current path using
‘ls’ without hidden directories

81 Linux Commands by www.server-computer.com – Most useful Linux commands  8

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

# ls

Listing including hidden files - default ls command will not list hidden objects, to see the
hidden objects you have to use option ‘-a’

# ls -a

Long list (it display detailed info) - when you use ‘ls’ command it will list files & directories
without their permissions, owner, group and other details, ‘-l’ option will display owner,
group, others, Size and time, which is called as long list.

# ls -l

List files & directories separated by comma - if there is a requirement that we have to list all
the files and directories separated by comma and import to CSV file '-m' is the best option to
use
# ls -m

81 Linux Commands by www.server-computer.com – Most useful Linux commands  9

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

List remote directory files & directories with & without color – list remote directory content
with color and without color below is the example

ls --color=always

Without color, here all the files and directories will display in block color

# ls --color=never

List only directory using option ‘-d’ - option ‘-d’ will display only directory path without its
content

# ls -d /etc/

List files & directories detailed time stamp - As we can see above -l option, which will
provide long, output, but time stamp is not detail (Example: no year), by following below
example it will provide time stamp details including time zone and seconds

# ls -l --time-style=full-iso

Display files and directories its time stamp as “YY-MM-DD HH:MM” - No need to think a lot to
list files and directories with Year-Month-Date Hours and Minutes format

81 Linux Commands by www.server-computer.com – Most useful Linux commands  10

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

# ls -l --time-style long-iso

List objects its time stamp as “MM-DD HH:MM” List all files & directories with date format YY-
MM-DD HH:MM

# ls -l --time-style iso

Display files & directories with customized time stamp format - Here in this option we can
mention date command options to customize time stamp as required

# ls -l --time-style="+%Y-%m-%d %H:%M:%S"

Note: refer man date command for more options

List Only Group Name without User name (Owner)

# ls -lg

List Only Owner Name without Group Name - ls command will list only user name (owner
name) excluding group details we have to use ‘-G’ option along with option ‘-l’ option

# ls -lG

List files & directories in human readable format - ls command will give you a nice human
readable format of ls command output use option ‘-lh’

# ls -lh

81 Linux Commands by www.server-computer.com – Most useful Linux commands  11

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

List assigned inode number of files and directories - we can also list the inode numbers of files
and directories using option ‘-i’

# ls -i

Files & directories, directories should append with / (slash) - To append the directories with /
(slash) we have to use option ‘-p’. If you observe below example output all the directories
ended with / (slash).

# ls –p
a anaconda-ks.cfg b c dir1/ dir2/ initial-setup-ks.cfg

Print files & directory names in quoted format - As we can list the files and directories using ls
command, file names will be printed as in quotes format using -Q option

# ls -lQ
# ls -Q

Sort the list by time stamp- you can sort the files and directories by its time, this option will list
old time stamp below newer up, which is most useful option to know new files

# ls -lt

Print in reverse - as above example prints output old files below and newer files up. using ‘-r’
option print in reverse way, old first and new last

# ls -ltr

List recursively - using option ‘-R’ you can list files and directories in recursively

81 Linux Commands by www.server-computer.com – Most useful Linux commands  12

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

# ls -R

Print the allocated size of each file, in blocks, using option ‘-S’ you can sort by file size

# ls -lS

Sort by alphabetical order – List files alphabetical order you have to use -X option

# ls –lX

List with tab space- ls command default will display file space as eight columns, using -T we can
print with more tab space in between files

# ls -T1

Print file names in one row - using option -1 (numeric number 1)

# ls -1

Let us know the ls command version details and author details

81 Linux Commands by www.server-computer.com – Most useful Linux commands  13

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com

81 Linux Commands by www.server-computer.com – Most useful Linux commands  14

Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube

You might also like