20 Basic Linux commands for beginners with examples and syntax

The Terminal on Linux systems is one of the most might tools, which can give you an interface to control almost everything on your system. It is quite similar to the ‘Command Prompt’ on Windows but is even more powerful than that. There are thousands of Linux terminal commands, and if you want to be a Linux warrior, get started with memorizing all the commands. But there are some common Linux terminal commands, which all users should know, lest they need to switch to Linux temporarily, at some point of their life, from the comfort zone of Windows. I am providing the full list of Linux commands, which most users will need, and I am sure, you will thank me later, for offering this valuable piece of information.

Most of the basic Linux commands for beginners with example and syntax are discussed here, and at the end of the article, I will also be mentioning some common tricks to use on the Terminal for using the Linux commands in a better and a more convenient way. Without further discussion, let’s find out the list of all Unix commands, which can also be used on Linux.

 

Most Important Linux Commands for beginners

Basic Linux commands for beginners with examples and syntax

ls/ ls –ltr / ls <URL>

Similar to ‘dir’ on Command Prompt, ls in Linux is used to show the list of files and directories, which are available in the present working directory.

The ls -ltr command output will show the list of files and directories will be shown, along with the permissions of each of them.

With the ls <URL>, you can find the list of files and directories in a particular location, which is given by the URL.

Example: ls files/java/codes

This command will show the list of files and directories in the ‘codes’ folded, which is present in ‘files/java’.

 

pwd

With the ‘pwd’ command, the present working directory on the Terminal will be shown.

 

cd <URL>

The cd command in Linux is one of the most used commands in Linux, which is used to change the present working directory to a different one. Just type cd followed by the URL, to jump to a new directory.

Example: cd movies

This will move to the ‘movies’ folder. But the folder should be present in the working directory. The command ‘cd ~’ will take the user to the home directory.

 

cat <URL/filename>

The cat command in Linux is used to show the contents of a file, within a location, on the screen. If the URL is not specified, the file with the given filename should be present in the working directory, and if the file is present in a different URL, the complete URL, along with the filename needs to be entered.

Example:

cat c2f.java

This will show the contents of the file ‘c2f.java’ on the screen, and the file should be available in the present working directory.

cat java/files/c2f.java

This will show the contents of the file ‘c2f.java’, which is located in the directory files, which is within java, on the screen.

 

touch <URL/filename>

With the touch command, followed by the URL and filename, a new file with the given name will be created. A file structure with 0 bytes will be created, and you can edit it, with some desired application. If you just use enter the filename, but not the URL, the file with the given filename will be created in the present directory.

Example: touch files/documents/work.txt

A file, with the name ‘work.txt’ will be created in the documents folder, in the directory files.

 

cp <source URL> <destination URL> / cp –r <source URL> <destination URL>

If you are quite experienced on Windows, you copy files from one location to another. Yes, the cp command is used to copy files from the source to the destination. You will have to give two arguments, where the first one will be the location of the source file, and the second argument will be used to give the location of the destination.

The –r argument is used to copy directories.

Example: cp files/movies/slp.mp4 files/movies/English

It will copy the slp.mp4 file in files/movies, to the destination, which is files/movies/English. The file will be copied in the destination, and the source file will be retained.

 

mv <source URL> <destination URL>

This is quite similar to cut and paste in Windows, where the file from the source location will be moved to the destination, and the file from the source will be deleted.

Example: mv files/movies/slp.mp4 files/movies/English

It will move the file with the name slp.mp4 from files/movies to files/movies/English, and the source file will be deleted after the operation completes successfully.

 

rm <URL/filename> / rm –r <URL/filename>

The rm command is used to remove files from a given URL. The –r argument is used to remove or delete files recursively, or multiple files at once, including directories. If the filename is pointed directly, the file should be present in the working directory.

Example: rm files/contents/preface.pdf

This will remove the file with the name preface.pdf, from the location files/contents.

 

mkdir <URL/directory name>

With mkdir, a new directory will be created, in the given URL. If you directly write the name of the directory, after mkdir, the directory will be created right in the present working directory. To create multiple directories, you can even separate the directory name with spaces.

Example: mkdir files/pik/new

This will create a new directory with the name ‘new’, in the URL, ‘files/pik’.

 

rmdir <URL/directory name>

The rmdir command is used to remove the directory with a given name, from the given URL. Just like the other commands, if the directory name is entered, skipping the URL, the directory should be present in the present working directory.

Example: rmdir files/docs

This will remove the directory with the name docs, the directory files.

 

chmod <mode> <URL/filename>

The chmod is the command, which is used to change the permissions of a given file, in Linux system. Without the URL, if the filename is entered directly, the file should be available in the present working directory.

It is always a good idea to set the mode with octal coding, where 4 means read, 2 means write 1 means execute, and 0 means no permission. Thus, if you want to set read and write permissions, the number should 6 (or 4+2), and for read and execute permissions, it should be 5 (or 4+1). Thus, the permissions should be set, by adding up the values of each permission.

There should be three permissions to set, where the first one should be for the user, the second one for the group, and the third one for the other. The example will make the thing clear for you.

Example:

chmod 754 abc.txt

This will set the permissions for abc.txt, where the user will get all the permissions, the group will get only the read and execute permissions, and other users will only get read permissions.

chmod 777 bcd.txt

This will set the permissions for bcd.txt, where the present user, the group, and the other users will get all the read, write, and execute permissions.

 

clear

This will clear the terminal. It is similar to the ‘cls’ command in ‘Command Prompt’ in Windows.

 

wget <link>

The ‘wget’ command is used to download any link from the internet. It will download the contents from that link, and it will be located in the current working directory.

 

sudo <commands and arguments>

The ‘sudo’ command will allow the user to get superuser or administrator privileges to execute a particular command.

Example: sudo touch abc.txt

This will create a file with the name abc.txt, in the present working directory, and the command will be executed with administrator privileges. The sudo command is not helpful in this case, but, sudo command can be used to install and remove packages, along with offering a number of other functionalities, with the superuser privileges.

 

apt-get install <package name>

The apt-get command is used to download and install certain packages from the apt repository, which is the most common repository for numerous Linux distributions. The ‘apt search’ command can also be used to search for certain packages in the apt repository.

Only the superuser, or the administrator has the permission to download and install packages, and thus, the apt-get command should be followed by the ‘sudo’ command.

Example: sudo apt-get install vlc

This command will download and install the package with the name ‘vlc’ from the apt repository.

 

ping <address>

The ‘ping’ has similar syntax if compared to the ‘ping’ command on ‘Command Prompt’ on Windows. Ping is used to check whether a remote address exists and is also used to check the time required to send and receive a package of typically 64 bytes to and from the entered address. Ping will also resolve the IP address of a given website.

To stop the command from execution, just press ‘Ctrl+C’, on your keyboard.

Example: ping how2shout.com

This will ping how2shout.com and will show the website IP address, the time to send and receive 64 bytes of data to and from the website.

 

exit

Just use the ‘exit’ command to exit the terminal.

 

poweroff

This command is used to turn off the system. If the user does not have administrator privileges, the command should be ‘sudo poweroff’.

 

Reboot

This command is used to restart the Linux system. Just like the ‘poweroff’ command, the ‘restart’ command also require superuser privileges, if the user is not an administrator.

This was a list of Linux command, which you will need, being a newbie to Linux. This will surely help you if you want to join some free Linux training for beginners. Bookmark this link today, and you will surely not regret it. You can even find list of Linux commands, which are meant for advanced users, which you will hardly need right now, being a newbie. If you want to dig more into the commands, you can even come to know some additional arguments for the fundamental commands, which are given above. The additional arguments will open new possibilities for you, which you will certainly need, if you start loving Linux, and want to use it as your primary operating system.

Some extra information

Apart from providing the fundamental Linux commands list, I also promised to give some Linux command line tricks, or some extra information, which will help you either now or then. Let’s find them out.

Accessing files with spaces

If you want to access files with spaces, create directories with spaces, or want to enter into directories with spaces, just keep the name of the directory within single quotes, else the directory will not be found by Linux.

Example: cd ‘how 2 shout’

Or,

cd how 2 shout

This will move into the directory with the name ‘how 2 shout’, in the current directory.

* But it is not a good practice to enter spaces in filenames and directories. Use ‘_’ instead.

Navigating through previous commands

You can use the up and down arrow keys to navigate through the previous commands.

Stopping command execution

Use ‘Ctrl+C’ to stop a command from getting executed. If it doesn’t work, ‘Ctrl+z’ should work.

Editing files inside the Terminal

Almost all Linux distributions come with a pre-installed text editing application named ‘nano’. Just type nano, followed by the filename to get a decent text editing interface, great for basic tasks.

Example: nano abc.txt

This will create a text file with the name abc.txt, and it will be available for editing instantly, in the ‘nano’ text editor.

Hope the small list of Linux command for beginners was helpful for you. Want to get more such commands to master Linux? Comment your opinion down, if you want it, and I will cover it soon.

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.