Linux Basic Cmds
Linux Basic Cmds
Website Builder
Hosting
VPS
Domain
Pricing
Login
Cart
WordPressVPSJoomla!DrupalEmailGlossaryVideo TutorialsWebinars
search
VPS
May 13, 2021
Artūras B.
9min Read
1. pwd command
Use the pwd command to find out the path of the current working
directory (folder) you’re in. The command will return an absolute
(full) path, which is basically a path of all the directories that starts
with a forward slash (/). An example of an absolute path
is /home/username.
2. cd command
To navigate through the Linux files and directories, use
the cd command. It requires either the full path or the name of the
directory, depending on the current working directory that you’re in.
Let’s say you’re in /home/username/Documents and you want to
go to Photos, a subdirectory of Documents. To do so, simply type
the following command: cd Photos.
Another scenario is if you want to switch to a completely new
directory, for example,/home/username/Movies. In this case, you
have to type cd followed by the directory’s absolute path: cd
/home/username/Movies.
There are some shortcuts to help you navigate quickly:
On a side note, Linux’s shell is case sensitive. So, you have to type
the name’s directory exactly as it is.
3. ls command
The ls command is used to view the contents of a directory. By
default, this command will display the contents of your current
working directory.
If you want to see the content of other directories, type ls and then
the directory’s path. For example,
enter ls /home/username/Documents to view the content
of Documents.
There are variations you can use with the ls command:
4. cat command
cat (short for concatenate) is one of the most frequently used
commands in Linux. It is used to list the contents of a file on the
standard output (sdout). To run this command, type cat followed by
the file’s name and its extension. For instance: cat file.txt.
Here are other ways to use the cat command:
cat >
filename creates a
new file
cat filename1
filename2>filename
3 joins two files (1
and 2) and stores the
output of them in a
new file (3)
to convert a file to
upper or lower case
use, cat filename |
tr a-z A-Z
>output.txt
5. cp command
Use the cp command to copy files from the current directory to a
different directory. For instance, the command cp
scenery.jpg /home/username/Pictures would create a copy
of scenery.jpg (from your current directory) into
the Pictures directory.
6. mv command
The primary use of the mv command is to move files, although it
can also be used to rename files.
The arguments in mv are similar to the cp command. You need to
type mv, the file’s name, and the destination’s directory. For
example: mv file.txt /home/username/Documents.
To rename files, the Linux command is mv oldname.ext
newname.ext
7. mkdir command
Use mkdir command to make a new directory — if you type mkdir
Music it will create a directory called Music.
There are extra mkdir commands as well:
To generate a new
directory inside
another directory,
use this Linux basic
command mkdir
Music/Newfile
use the p (parents)
option to create a
directory in between
two existing
directories. For
example, mkdir -p
Music/2020/Newfile
will create the new
“2020” file.
8. rmdir command
If you need to delete a directory, use the rmdir command.
However, rmdir only allows you to delete empty directories.
9. rm command
The rm command is used to delete directories and the contents
within them. If you only want to delete the directory — as an
alternative to rmdir — use rm -r.
Note: Be very careful with this command and double-check which
directory you are in. This will delete everything and there is no
undo.
15. df command
Use df command to get a report on the system’s disk space usage,
shown in percentage and KBs. If you want to see the report in
megabytes, type df -m.
16. du command
If you want to check how much space a file or a directory takes,
the du (Disk Usage) command is the answer. However, the disk
usage summary will show disk block numbers instead of the usual
size format. If you want to see it in bytes, kilobytes, and megabytes,
add the -h argument to the command line.
SIGTERM (15) —
requests a program
to stop running and
gives it some time to
save all of its
progress. If you don’t
specify the signal
when entering the kill
command, this signal
will be used.
SIGKILL (9) —
forces programs to
stop immediately.
Unsaved progress
will be lost.
Besides knowing the signals, you also need to know the process
identification number (PID) of the program you want to kill. If you
don’t know the PID, simply run the command ps ux.
After knowing what signal you want to use and the PID of the
program, enter the following syntax:
kill [signal option] PID.
To Sum Up
Basic Linux commands help users execute tasks easily and
effectively. It might take a while to remember some of the basic
commands, but nothing is impossible with lots of practice.
In the end, knowing and mastering these basic Linux commands will
be undoubtedly beneficial for you. Good luck!
THE AUTHOR
Artūras B.
By entering your email, you'll be subscribed to the Hostinger newsletter. You can unsubscribe any time. See our privacy policy
Sign Up
Related tutorials
02 Dec • VPS
By Susan Curtis
29 Nov • VPS
By Prithviraj S.
20 Nov • VPS
By Domantas G.
Comments
Leave a comment
Vimal
July 30 2019
REPLY
GOOD
Sunny
December 20 2019
REPLY
Very helpful article, Good job Art
Adrian
May 24 2020
REPLY
Very good explanations! Thanks a lot!
REPLY
Thank you very much. Good article
xmax
July 08 2020
REPLY
Very helpful info, indeed
REPLY
Man, you're a lifesaver! REALLY helpful to see all useful commands with their switches
all in one place.
Tomislav T.
September 06 2020
Always happy to help, Syed! :)
Sina
August 17 2020
REPLY
Thanks art That was Very Very Helpful!
Hasan Murtaza
August 17 2020
REPLY
Thanks
boe
August 23 2020
REPLY
thanks
happy
August 31 2020
REPLY
Love from China.
Mehmood Qazi
September 20 2020
REPLY
Very helpful
Tomislav T.
November 11 2020
Happy to help, Mehmood.
krikor bedrossian
October 17 2020
REPLY
Excellent, thank you :-)
Vakarė
February 02 2021
Happy to help!
REPLY
Really Very Useful
Ravichandran VN
November 17 2020
REPLY
Thanks for sharing the valuable information.
dhruv
November 23 2020
REPLY
Thanks for this amazing content!!! LIFESAVER!!!.......
Vakarė
February 09 2021
Happy it helped!
ugesh
December 12 2020
REPLY
very informative . thanks
kamyogi
December 23 2020
REPLY
Thank you very much Art. Very useful. It has changed a bit my attitude towards Linux.
Nizor
January 11 2021
REPLY
This was very helpful. Thanks
ajay
January 27 2021
REPLY
its very helpful to know commands easily
Benji
February 27 2021
REPLY
Lots of lives saved by this command lines. Thanks!
Ulita Dso'za
May 08 2021
REPLY
Thank you....!!! It is very helpful for beginners..........
Bethwel Ombewa
July 07 2021
REPLY
Very helpful information
sharfat hussain
July 07 2021
REPLY
very informative Linux command
Grammy R. Codeislow
July 11 2021
REPLY
Your documentation is incredibly useful. Thanks for taking the time to make this.
Leave a reply
By using this form you agree with the storage and handling of your data by this website. *
Submit
Our mission is to make life easier for website developers and their customers. We do it by offering easy to use,
fast and reliable web hosting services.
And More
HOSTING
COMPANY
About Hostinger
Contact Us
DOMAINS
HELP
INFORMATION
Server Status
Recommend Hostinger
Reviews
Payment Methods
LEGAL
Privacy Policy
Terms of Service
© 2004-2021 hostinger.com - Premium Web Hosting, Cloud, VPS & Domain Registration Services.
Prices are listed without VAT