Linux Commands
Linux Commands
Prepared for:
Public
Prepared by:
Ankam Ravi Kumar
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
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.
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.
Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com
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.
Without any options cat can show the content of text file, example shown above screenshot.
Using –b option cat command will show the content with numbered lines, excluding blank
lines.
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
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.
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
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
Listing current directory content - You can list out all files and directories in current path using
‘ls’ without hidden directories
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
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
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"
# 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
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
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
# ls -1
Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube
81 Linux Commands – You must Learn https://www.server-computer.com
Follow Us on social media: Facebook | Twitter | Reddit | LinkedIn | Website | Blog | YouTube