30 Basic Linux Commands For Beginners [Linux 101]

Basic Linux Commands

When I was introduced to Linux, I had a pretty hard time getting used to and learning Linux commands. There’s no secret to learning Linux in a day or two easily but to practice, fail, stand up and practice again, and learn from your mistakes. The easiest way to learn Linux is not to abandon it if you don’t understand how it works. In this article, let’s look at some of the basic Linux commands for beginners.

This list of Linux terminal commands contains all the common commands. Think of it as a Linux command cheat sheet as it contains almost all the basic ones to get you started.

Basic Linux Commands: Linux For Beginners

1. mkdir

The name says it all. The mkdir command in Linux is used to create a new directory or, if you’re coming from Windows, a Folder.

mkdir folder name

Where “folder name” is the name of the folder you want to create.

2. echo

Echo is the simplest command in Linux. It is used to display text that is passed after the space in the command.

focusblast@pop-os:~$ echo fossbytes
fossbytes

The echo command might seem useless, but it is used in debugging code and determining the program’s state. If you know a little bit of programming, think of it as a print statement that only outputs a string.

Python3

print("fossbytes")
>> fossbytes

3. pwd

PWD stands for Print Working Directory. This gives us a quick way of finding out the working directory path.

focusblast@pop-os:~$ pwd
/home/focusblast

4. cd

Cd is an acronym for the change directory. As the name suggests, it is used to temporarily change the directory you’re working in.

focusblast@pop-os:~$ cd /Desktop
focusblast@pop-osDesktop:~/Desktop$

5. cp

The command cp is used to copy and paste a file to a directory specified as the second argument.

focusblast@pop-os:~/Desktop$ cp new.txt /home/focusblast/Downloads

In the above command, “new.txt” is the file that we copy to the directory “/home/focusblast/Downloads.”

6. mv

The mv command in Linux stands for “Move.” It is used to move files or directories from one place to another. Consider a file “move.” To move it to the Downloads folder, all we need to do is:

focusblast@pop-os:~/Desktop$ mv move /home/focusblast/Downloads

7. man

The manual page (man) command is like software documentation using which you can know what a particular command does and how it works:

focusblast@pop-os:~$ man cp

CP(1)                            User Commands                           CP(1)

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

       Mandatory  arguments  to  long  options are mandatory for short options
       too.

       -a, --archive
              same as -dR --preserve=all

       --attributes-only
              don't copy the file data, just the attributes

       --backup[=CONTROL]
 Manual page cp(1) line 1 (press h for help or q to quit)

8. ls

The ls command is used for listing the contents of a directory.

focusblast@pop-os:~$ ls

Downloads      Public   Documents
snap          Templates  Videos
Music        Pictures    VMs

9. cat

The cat command is used to print or merge the content from the line where the first file ends.

focusblast@pop-os:~$ cat file1
cat command example - basic linux commands for beginners

The command to merge two files and create a new file or merge them in any two files would be.

cat file1 file2 > file3 #This will merge files in file 1 and file 2 in a new file

Now, the cat command has a lot of commands that we couldn’t fit in this article. You can use the command “man cat” to learn more about it.

10. rm

The rm command is used to remove files and directories. You’ll need both rm and -r (recursive) to remove a directory.

rm new2.txt #removes the file
sudo rm -rf directory #removes the directory

The f in “-rf” is used to tell rm to ignore files and arguments that don’t exist.

11. zip/unzip

Zip is used to create a new zip file, whereas Unzip is used to unzip zipped files. Here’s how you you Zip and Unzip commands.

focusblast@pop-os:~$ zip newzipfile.zip file1.txt file2.txt

In the above command, newzipfile.zip is the name of the zipped file in which we’re going to put the two text files file1.txt and file2.txt.

To extract all the files from a zipped file using the command.

focusblast@pop-os:~$ unzip newzipfile.zip

Replace “newzipfile” with the name of the zipped file you want to extract.

12. wget

wget is a handy command that can help you download files from the internet. Here’s how to use it:

wget "download link"

13. top

Similar to Windows Task Manager, top command shows you the list of running processes and how much CPU is being used.

top command
focusblast@pop-os:~$ top

14. history

The history command is used to display the commands that you’ve typed before.

focusblast@pop-os:~$ history

15. wc

The wc command is used to count the number of lines (-l), words (-w), bytes (-c), and characters (m).

focusblast@pop-os:~$ wc -l filename.txt
33 filename.txt

16. clear

As the name suggests, clear is used to clear the terminal screen.

focusblast@pop-os:~$ clear

17. passwd

You guessed it right! The passwd command is used to change the password of the user account. To use it, type passwd followed by the username.

focusblast@pop-os:~$ passwd focusblast

18. chown

The chown command is used to transfer the ownership of files. Let’s assume there’s a file named file1 and you’re user0. You want to transfer the ownership to user1.

focusblast@pop-os:~$ chown user1 file1.txt

You can also transfer the ownership to root using the command.

sudo chown root file1.txt

19. apt

Apt stands for Advanced Packaging Tool. It is one of the most popular and powerful package managers for Ubuntu/Debian. For starters, a package manager essentially automates the process of installing and removing applications.

The following command installs the flameshot application, which is one of the most popular screenshot tools on Linux.

sudo apt install flameshot

20. reboot

The name says it all. Reboot command is used to reboot, shut down, or halt the system.

reboot

21. chmod

The chmod command is used to change the read (-r), write (-w), and execute (-x) instructions of a file. An example of chmod command would be:

chmod 742 program.sh

Here’s what the numbers mean.

NumberPermissionRepresentation
0No Permissions
1Execute Permission–x
2 Write Permission-w-
3Write and Execute-wx
4Read Permissionr–
5Read and Executer-x
6 Read and Writerw-
7Read, Write, and Executerwx
Linux permissions

The first number (7) in the above command represents the permissions that you’re giving to the user i.e. Read, Write, and Execute.

The second digit (4) is the permissions given to the file itself, which, in this case, is “Read Permissions only.”

The third and final digit (2) represents the permissions given to everyone who’s not a part of the group.

22. grep

The grep command is used to search and find text in a file.

grep "fossbytes" text.save
grep command - basic linux commands for beginners

23. locate

Similar to the search command in Windows, the locate command is used to locate files in Linux.

$ locate text.save
/home/focusblast/Desktop/text.save

24. sudo

The only command of all that you’ll end up using the most. The acronym for Sudo is SuperUser Do, using which you can fiddle with the files that require root permissions.

Mind you, if a file needs root privileges, it’s probably important to the OS. Hence, we suggest not to play around if you don’t know what you’re doing.

25. hostname

The hostname command is used to know your device name. Additionally, using the -I argument will help you know your IP address.

$ hostname
pop-os
$ hostname -I
192.1.1.1

26. exit

The exit command can be used to close the terminal quickly.

27. df

Suppose you want to know the space in every disk partition, type df. The default space metric is Kilobytes but, you can use the argument “-m” to change it to Megabytes.

$ df -m
df -m

28. netstat

The netstat command can be used to check the network statistics, interface statistics, routing table information, and much more.

$ netstat

29. fdisk

The fdisk command will list all the partitions and the information like the partition name, sectors, size, and partition types. fdisk needs superuser permissions to run.

$ sudo fdisk -l

30. Nano

Nano is my favorite text editor in Linux. If you want to open up a text file, you can type “nano” followed by the “filename” if you’re in the directory where the file is present to open it up.

nano text editor

When you’re done editing the text file, press the key combination “Ctrl+O” to write the changes and “Ctrl+X” to exit. To learn more about Nano, you can also go to the help section by pressing “Ctrl+G.”

Bonus Command For Fun

31. sl

You can install sl using apt, and a train will appear whenever you type sl instead of the ls (list directory) command that we talked about earlier.

sl command
sudo apt install sl

The above commands are just the tip of the proverbial iceberg. There’s a lot more to Linux than what meets the eye. To acquire in-depth knowledge of Linux and make a career out of it, we suggest reading this free book.

Similar Posts