So, are you planning to switch from Windows to Linux or have you recently made the switch to Linux? Oops! What am I asking? Why else would you be here?
In my earlier experience as a newcomer, Linux commands and terminals were quite intimidating. I had concerns about the commands and wondered to what extent I needed to remember and memorize them to become proficient and fully functional with Linux.
Undoubtedly, online documentation, Linux books, man pages, and the user community provided significant assistance.
However, I strongly believe that there should be an article featuring basic Linux commands in easy-to-learn and understood language.
These motivations inspired me to master Linux and make it more user-friendly. This article is a step towards that goal.”
1. ls Command
The command ‘ls‘ stands for ‘List Directory Contents‘, which is used to display the contents of the folder, whether they are files or subfolders, from which the command is executed.
ls
The ‘ls -l‘ command lists the contents of the folder in a detailed, long listing format.
ls -l
The ‘ls -a‘ command lists the contents of a folder, including hidden files that start with '.'
.
ls -a
In Linux, a file name starting with '.'
is considered hidden. In Linux, every file, folder, device, or command is treated as a file.
The result of the ls -l command is:
- File Type – The first character represents the file type (
'-'
for a regular file,'d'
for a directory,'l'
for a symbolic link, etc.). - Permissions – The next nine characters represent the file’s permissions for the owner, group, and others. These characters can include
'r'
for read,'w'
for write, and'x'
for execute permissions. - Number of Links – Indicates the number of hard links pointing to the file or directory.
- Owner and Group – Specifies the user (owner) and group associated with the file or directory.
- File Size – Shows the size of the file in bytes.
- Modification Time – Displays the date and time when the file or directory was last modified.
- File or Directory Name – The actual name of the file or directory.
For more “ls” command examples read our series of articles:
2. lsblk Command
The ‘lsblk‘ command, short for ‘List Block Devices,’ displays block devices by their assigned names (excluding RAM) in a tree-like format on the standard output.
lsblk
The ‘lsblk -l‘ command lists block devices in a ‘list‘ structure rather than a tree-like fashion.
lsblk -l
lsblk is a very useful and easy way to identify the name of the new USB device you just plugged in, especially when you have to work with disks or blocks in the terminal.
3. md5sum Command
The ‘md5sum‘ stands for ‘Compute and Check MD5 Message-Digest‘. MD5 checksum (commonly referred to as a ‘hash‘) is used to match or verify the integrity of files that may have changed due to a faulty file transfer, disk error, or non-malicious interference.
md5sum teamviewer_linux.deb 47790ed345a7b7970fc1f2ac50c97002 teamviewer_linux.deb
The user can compare the generated md5sum with the one provided officially. MD5sum is considered less secure than sha1sum, which we will discuss later.
4. dd Command
The dd command stands for ‘Convert and Copy a file‘ and can be utilized to convert and copy a file. Most often, it is used to copy an ISO file (or any other file) to a USB device (or another location), making it suitable for creating a bootable USB stick.
dd if=debian.iso of=/dev/sdb1 bs=512M; sync
The dd command takes some time ranging from a few seconds to several minutes in execution, depending on the size and type of file and read and write speed of the Usb stick.
5. uname Command
The uname command stands for (Unix Name), and prints detailed information about the machine name, operating system, and kernel version.
uname -a Linux TecMint 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
The result of the uname -a
command is:
- “Linux“: The machine’s kernel name.
- “tecmint“: The machine’s node name.
- “6.2.0-39-generic“: The kernel release.
- “22.04.1-Ubuntu SMP“: The operating system release version.
- “x86_64“: The architecture of the processor.
- “GNU/Linux“: The operating system name.
6. history Command
The history command stands for History (Event) Record, it prints the history of a long list of executed commands in the terminal.
history
Note: Pressing 'Ctrl + R'
allows you to search for previously executed commands, enabling your command to be completed using the auto-completion feature.
(reverse-i-search)`if': ifconfig
For more examples of history commands, please refer to our series of articles:
7. sudo Command
The “sudo” (superuser do) command allows a permitted user to execute a command as the superuser or another user, as specified by the security policy in the sudoers list.
sudo apt update
Note: sudo allows users to borrow superuser privileges, while a similar command ‘su‘ allows users to log in as superusers. Sudo is safer than su.
It is not advised to use sudo or su for day-to-day normal use, as it can result in serious errors if accidentally you do something wrong, that’s why a very popular saying in the Linux community is:
“To err is human, but to really foul up everything, you need a root password.”
For more examples of sudo commands, please refer to our series of articles:
8. mkdir Command
The (make directory) creates a new directory with a name path. However is the directory already exists, it will return an error message “cannot create a folder, folder already exists”.
The mkdir command (make directory) is used to create a new directory with a specified path. However, if the directory already exists, it will return an error message stating, ‘cannot create a folder, folder already exists‘.
mkdir tecmint
Directories can only be created within folders for which the user has write permissions.
9. touch Command
The touch command stands for ‘update the access and modification times of each FILE to the current time.’ The ‘touch‘ command creates the file only if it doesn’t exist. If the file already exists, it will update the timestamp but not the contents of the file.
touch tecmintfile
The `touch` command can be used to create a file in a directory for which the user has written permission, only if the file doesn’t already exist there.
10. chmod Command
The “chmod” command stands for “change file mode bits,” which alters the file mode (permissions) of each specified file, folder, script, etc., according to the specified mode.
There exist 3 types of permission on a file (folder or anything but to keep things simple we will be using file).
Read (r)=4 Write(w)=2 Execute(x)=1
So if you want to give only read permission on a file it will be assigned a value of ‘4‘, for write permission only, a value of ‘2‘ and for execute permission only, a value of ‘1‘ is to be given. For read and write permission 4+2 = ‘6‘ is to be given, and so on.
Now, permission needs to be set for 3 kinds of users and user groups. The first is the owner, then the user group, and finally the world.
rwxr-x--x abc.sh
Here the root’s permission is rwx (read, write, and execute). usergroup to which it belongs is r-x (read and execute only, no write permission) and for the world is –x (only execute).
To change its permission and provide read, write, and execute permission to the owner, group, and world.
chmod 777 abc.sh
only read and write permission to all three.
chmod 666 abc.sh
The read, write, and execute to the owner and only execute to group and world.
chmod 711 abc.sh
chmod is one of the most crucial commands that proves beneficial for both system administrators and users. In a multi-user environment or on a server, this command is indispensable, as incorrectly setting permissions can render a file inaccessible or grant unauthorized access to individuals.
11. chown Command
The chown command stands for “change file owner and group“, which is used to change the owner and/or group of a file or directory.
Below is an example of how the chown command is typically used.
chown newowner:newgroup filename
For instance, if you want to change the owner of a file named “example.txt” to a user named “tecmint” and a group named “users“, the command would be:
chown tecmint:users example.txt
12. apt Command
On Debian-based distributions such as Ubuntu and Linux Mint, the apt command stands for (Advanced Package Tool), which is used to install, upgrade, and manage software packages on a system from the command line.
sudo apt search wget sudo apt install wget sudo apt update
The apt command is considered more advanced and intelligent as compared to yum or dnf command.
13. tar Command
The tar command is a Tape Archive that is useful in the creation of an archive, in several file format and their extraction.
tar -zxvf abc.tar.gz (Remember 'z' for .tar.gz)
tar -jxvf abc.tar.bz2 (Remember 'j' for .tar.bz2)
tar -cvf archieve.tar.gz(.bz2) /path/to/folder/abc
Note: A ‘tar.gz‘ means gzipped. ‘tar.bz2‘ is compressed with bzip which uses a better but slower compression method.
14. cal Command
The “cal” (Calendar), is used to display the calendar of the present month or any other month of any year that is advancing or passed.
cal
Show the calendar of the year 1835 for February, which already has passed.
cal 02 1835
Shows the calendar of the year 2145 for July, which will be advancing
cal 07 2145
Note: You don’t need to turn the calendar back by 50 years, nor do you need to perform complex mathematical calculations to determine the day you were born or the day your upcoming birthday will fall on.
15. date Command
The date command is used to display the current date and time. It can also be used to set the system date and time.
To display the current date and time.
date
To display the current date in the format “YYYY-MM-DD“.
date +"%Y-%m-%d"
To set system date and time.
sudo date MMDDhhmm[[CC]YY][.ss]
The above command allows you to set the system date and time. Replace MM, DD, hh, mm, CC, YY, and ss with the desired values for month, day, hour, minute, century, year, and second, respectively.
Note: The date command is highly useful in scripting, especially for time and date-based operations. Moreover, changing the date and time using the terminal can make you feel like a true GEEK! (Of course, you need to have root permissions to perform this operation, as it involves a system-wide change).
16. cat Command
The cat command stands for (Concatenation), which means (join) two or more plain files and/or print contents of a file on standard output.
To display the contents of a file.
cat filename
To concatenate multiple files means the following command concatenates the contents of file1 and file2 and displays the result in the terminal.
cat file1 file2
The content of a.txt, b.txt, c.txt, and d.txt will be combined and appended to the end of the abcd.txt file.
cat a.txt b.txt c.txt d.txt >> abcd.txt
cat abcd.txt
Note: The “>>
” and “>
” are called append symbols. They are used to append the output to a file and not to standard output.
The “>
” symbol will delete a file that already existed and create a new file hence for security reasons it is advised to use “>>
” that will write the output without overwriting or deleting the file.
Before proceeding further, I must let you know about wildcards (you would be aware of wildcard entries, in most of Television shows) Wildcards are a shell feature that makes the command line much more powerful than any GUI file manager.
You see, if you want to select a big group of files in a graphical file manager, you usually have to select them with your mouse. This may seem simple, but in some cases, it can be very frustrating.
For example, suppose you have a directory with a huge amount of all kinds of files and subdirectories, and you decide to move all the HTML files, that have the word “Linux” somewhere in the middle of their names, from that big directory into another directory.
What’s a simple way to do this? If the directory contains a huge amount of differently named HTML files, your task is everything but simple!
In the Linux command line that task is just as simple to perform as moving only one HTML file, and it’s so easy because of the shell wildcards. These are special characters that allow you to select file names that match certain patterns of characters.
This helps you to select even a big group of files by typing just a few characters, and in most cases, it’s easier than selecting the files with a mouse.
Here’s a list of the most commonly used wildcards :
Wildcard Matches * zero or more characters ? exactly one character [abcde] exactly one character listed [a-e] exactly one character in the given range [!abcde] any character that is not listed [!a-e] any character that is not in the given range {debian,linux} exactly one entire word in the options given
The !
is called not a symbol, and the reverse of the string attached with '!'
is true.
17. cp Command
The cp command stands for (copy), it copies a file from one location to another location.
cp /home/user/Downloads abc.tar.gz /home/user/Desktop
Note: The cp is one of the most commonly used commands in shell scripting and it can be used with wildcard characters (describe in the above block), for customized and desired file copying.
18. mv Command
The mv command moves a file from one location to another location.
mv /home/user/Downloads abc.tar.gz /home/user/Desktop
Note: The mv command can be used with wildcard characters. mv should be used with caution, as moving of system/unauthorized files may lead to security as well as a breakdown of the system.
19. pwd Command
The pwd command (print working directory), prints the current working directory with the full pathname from the terminal.
pwd /home/user/Desktop
Note: The pwd command won’t be frequently used in scripting but it is an absolute lifesaver for a newbie who gets lost in the terminal in their early connection with Linux. (Linux is most commonly referred to as nux or nix).
20. cd Command
Finally, the frequently used cd command stands for (change directory), which changes the working directory to execute, copy, move write, read, etc. from the terminal itself.
cd /home/user/Desktop pwd /home/user/Desktop
Note: The cd command comes to the rescue when switching between directories from the terminal. The "cd ~"
will change the working directory to the user’s home directory, which is very useful if a user finds themselves lost in the terminal. The "cd .."
will change the working directory to the parent directory of the current working directory.
Conclusion
These commands will undoubtedly enhance your comfort with Linux. However, this is not the conclusion. Soon, I will introduce additional commands that will prove valuable for ‘Middle-Level Users‘. You will observe a promotion in your user-level status, progressing from a newbie to a middle-level user.
In the next article, I will be coming up with commands like ‘Kill‘, ‘ps‘, and ‘grep‘.
dd is Disk Dump. I use it to back up a hard drive to a
.iso
file before I do any work on it ie recover files, upgrade os, etc.Nicely paced article
As i know; is a meta character which is used to separate two commands then what is the use of command after ; here in this dd command and what bs=512M used for?
why it comes permission denied when we access some folder?
nice one
Include the command vi
I really liked it, please add more such topics, thanks.
You forgot to tell the readers the “root@tecmint:” refers to your computer and will be different for each owner…. Otherwise this is a useful article.
Although it is directed to power users, most Linux users will find Ubuntu or Mint, along with the many other GUI, will be just fine! Operating from the terminal is complex and fun at the same time just remember be careful with commands.
I think this guide is so nice, well fitted. Just missing a command, which is really useful for new people coming, looking at logs :) to solve problems.
I’m talking about head and tail and grep. Those commands are necessary to inspect logs in a better/faster/easier way and can be “added” aside the “cat” section you made.
Also, an Alias section would be mega useful to don’t force users to use ctrl+r to remember their commands.
I’m one of those people hating viruses along Windows, so I’ve switched to Debian and I know what I say.
Nice work.
Very good tutorial and very useful
This is very useful and very well explained.
Thanks !
Very good introduction from Windows to Linux. It should be placed at first position of Section 2, before detailed explanations or examples given for each of the commands. Thank you from a windows defector!
I want to learn LINUX please teach me.
@Jay,
Here is the exclusive course module from TecMint, compiled for newbies only to learn and improve their Linux skills..
https://www.tecmint.com/free-online-linux-learning-guide-for-beginners/
If i done Linux (RHCE)…..is jobs in market that i can get easily….
Dear Sir,
What is the future in Linux ?… I want to know….is there any growth?….is it good field in Linux (RHCE)?…please help me…
ia verry happy for the section
Welcome ravendhran,
Keep connected for more such posts.
Hi avishek, this website is very useful for me. Can you tell me what other stuff as a newbie i need to learn to give an interview for position of sys admin intern?
Welcome Vatsal. Have good command over Scripting (Shell/Python/perl) and general service which includes but not limited to Apache, MySQL,…. Also have sound knowledge of networking and network Protocols and what ever you can learn just keep doing…
Amazing website. I am a newbie, however I have a quick question in regards to “cat” command and the example above:
oot@tecmint:~# cat a.txt b.txt c.txt d.txt abcd.txt
Are you trying to concatenate 5 files (a, b, c, d, abcd.txt) and print the content, or are you trying to concatenate a, b, c, d to abcd.txt? If the latter, should not this command be:
oot@tecmint:~# cat a.txt b.txt c.txt d.txt >>abcd.txt
Again – I have learnt a lot, and I am trying to follow every example. It took me a while to understand what was going on with the first command. Thank you!
Dear Romanator,
You are right. It is a mistake on my part.
The command should be
# cat a.txt b.txt c.txt d.txt >> abcd.txt
or
# cat a.txt b.txt c.txt d.txt > abcd.txt
Asking admin to amend it, please.
nice post with good explanation…
thank you
Welcome @ Dinesh
Thanks a loot
Welcome @ wahidullah
These are the very Basic commands in LINUX…Interested to know some more commands which will be useful too..
Thanking you…
how to add a user and how to delete a user plz put some example here
Here is the complete guide on how to add users and delete users in Linux.
https://www.tecmint.com/add-users-in-linux/
Dear Sir,
I am looking for lab session like
1) creating local repository by copying packages from DVD.
2) Installing & Configuring SAMBA Server step by step.
3) Creating Backup Server.
Thanks & Regards,
Amol Bhosale
Dear Amol,
The things you looking for, we already covered, juse use our search form to search for articles.
I also looking for installation and configuration on different servers like samba,dhcp,mailing servers etc.
PS – This page has now been honoured by being bookmarked on the Tool-bar!!!
:)
we are honoured @ Alex
Very nice work. As another ancient but new to Linux user: I Thank you!
Linux Lite suits my venerably old machine just fine – she hums along happily without the screaming and screeching with Windows…we are both happier :)
:)
Nice notes for beginner….thank you sir
Welcome @ Narasinhareddy
commands explained easily to understand…thanks
Welcome Late P.E.
The commands are explained nicely with good examples as well. Good job.
Oh! Thankyou Suresh.
It helps me out….thnx
Great to know it @ crazy Bani
As a noob, moving over to Linux, on an old PIII, Dell laptop, I appreciate your effort to introduce me to the command line. I also appreciate the links to find more command line usage.
My motivation to move to Linux was the age of my computer, the lack of support for the computer by Microsoft, (why throw away that which is usefull, and be forced to buy something new just to have to repeat it again, because Microsoft forces you to) and also to disprove the saying that an old dog ( 68 ) can’t be taught new tricks. The distro that I found that seems best suited to my needs and computer was Slitaz. TThank you Linux world.
Welcome. We are glad to have you apart of our world!!
Difficult to understand but thanks for your quote.
Welcome SIR,
we really feels inspired.
‘lsblk’ does not work on Redhat?
It works on RedHat. Btw… keep it up ABhishek Kumar…. !!
@ Amol
it works on all Distros.
Nice one
thanks
Apart of having a TERRIBLE English, your post is good. You’re a experienced computer user, you SHOULD have a good command of English please!!!!
John Susa, you might want to make sure that your command of english is 100% accurate before you start saying things like that.
“Apart of having….” ????
Lol. Well played sir.
The point is, it’s not English anymore. It’s Earthish.
What the hell is this????
The 1st ravisaive in the above example means that file is owned by user ravisaive.
The 2nd ravisaive in the above example means file belongs to user group ravisaive.
What is a “ravissaive”????
It’s a system USER.
This is a nice guide for someone who does more then check email and browse websites on a machine. The basic email/web guys would like more graphical style stuff though I think. It’d be neat if there was a side by side comparison of the command line and graphical tool (if available).
Nix?
Nux?
@ ken
sudo apt-get remove ubuntu is ok.
but if you mean sudo apt-get remove linux or yum remove linux
then dear i have to ask you, what the hell are you doing here ?
@ Cat and Scott no Linux user will be afraid of terminal. it is the curosity, the adventure, the fun that drives them to the world of Linux, they know that terminal (shell) is the soul of Linux and is much powerful that powershell or any other shell implemented in other OSes. if this is not true, most of us would have still be sticks to walls, gates and windows.
I agree, I am very new but it was the excitement of being able to control things more, to be able to play around with a command line and have the excitement of the risk of potentially being able to break things while playing, that is what drew me to Linux. You are dead right, someone who is afraid of the command line would not be trying to play with it, and would continue to point-and-click :-)
@ Rambo Tribble sure df is one of the important command but for sure a newbie in linux don’t have to bother much about his disk usages, and when you have to provide only 20 commands, whom will you select and whom to discard is a matter of debate, moreover df will surely be available in the next part of this tutorial.
I think that part about apt being superior to yum is pretty infamatory. It would be one thing if you actually had some kind of included reference to back it up. Or at the very least you could have included a brief explanation.
Honestly, I think they both have their strong points over one another. You can’t say that one is unequivocally better than the other, as they are both very mature.
I am a pacman user though. And just ask Allan, pacman f-ing rules! (At least is is certainly far faster than yum or apt)
yum :
yum Comes with Fedora and fedora like OS by default and is Widely supported by many RPM repositories which is Fairly easy to roll your own repository.
However, No “pinning” or other mechanisms for backing out updates, Somewhat confusing to create a hierarchy of “trust,” in terms of which repositories to use for which packages and No graphical update/management tool are the drawbacks of yum.
apt :
apt Somewhat has wider support across distributions (since its a Debian tool), which include Synaptic, a graphical GUI for doing updates and “Pinning” support, and uninstall support.
However, apt is Not a base part of the FC package set. Perhaps a slightly higher learning curve to use effectively.
Harder to use as a verb in jargon filled conversations. “I apted GIMP2 last night” as opposed to “Yum up that new GIMP2 package”
(apt is used by debian and debian like distro viz., ubuntu, kubuntu, fuduntu, kali, …….., etc and yum is used by fedora and fedora like os viz., redhat, centos, etc. The number of distros using apt is several times more than distros using yum as package manager. )
None of the two is perfect, but surely apt has an edge over yum. You better compare yourself.
sudo apt-get remove ubuntu
that is the evilest thing I can imagine
lol :)
Sure way to scare linux newbies away is starting to tell them about command line. First they must master normal use in windowed environment. When they have those skills and are interested in deeper dive in linux, then it’s time to start learning command line.
I agree. This leaves the impression that to use Linux one must learn the command line. For desktop use the command line is completely unnecessary.
I disagree. When I got my first computer, Windows 3.0 had just come out. But instead of installing it, I sat down and learned to work with DOS, and to this day I have never regretted it. It STILL comes in handy and has saved my yass a few times. After all, the operations you perform in a graphical environment are the same ones you perform from the command line. Knowing how to do them in their original, historical form is not going to hurt anybody and will do people a lot of good. It’s a little like learning Latin – once you study it a bit you start to understand English with a lot more depth.
I disagree.
This was exactly what I needed in coming to run Linux in an embedded environment with only a shell for access.
I would suggest adding “df” to your list. Keeping track of disk resources is always a good idea.
#20 has some duplicate code from #19. Otherwise, it’s a great tutorial :)
#20 has some duplicate code from #19 ???
of which kind and where?
Hi Sir,
I am into windows side,working as system admin,need to switch over to linux..so plz suggest what all the basic things need to learn in linux..tell me how to prepare myself..waiting for ur reply…
@kiran,
We always suggest newbies to start with basic Linux commands, we’ve a huge collection of basic Linux commands with examples to learn at https://www.tecmint.com/category/linux-commands/.