Menu

Basic Linux Commands You Should Know

Taufik Nurhidayat
5 min read
#linux #tutorial

Linux is famous for its command line or command line that is often typed in terminal applications. Often called command prompt, shell, terminal...


Linux is famous for its command line or command line that is often typed in terminal applications. Often called command prompt, shell, terminal, console or whatever it is basically the same, which is a text interface or display used to manage a program or the system itself.

If in Windows you can find CMD and Shell, in Linux it’s not much different. In Linux-based operating systems, the command line is very important, so we must know the basics of the Linux Command Line. Here you will learn the basics of command line or command line on Linux. What are the basic commands in Linux?

Opening Linux Terminal

To open the Linux terminal just press CTRL+Alt+T you can also directly search for the terminal application if the shortcut doesn’t work. When typing command line we must pay attention to the letters because command line is case sensitive which pays close attention to uppercase and lowercase letters, so be careful when typing command line on Linux or other OS. Because command line is case sensitive, it means if you type mkdir and MKDIR then it can be sure that the execution results will not be the same.

Basic Commands on Linux You Should Know

Display Directory Path

To display the path or location of a directory which can also be called a folder we must use pwd.

pwd

Basic Commands on Linux You Should Know

Change/Move Directory

After knowing how to display the directory location, now it’s time to change directories, with this command you can move from the home directory to the Documents directory for example. The command is cd for example as follows.

cd Documents

To return to the home directory just type cd only, if you are a super user then you will return to the root directory or /

Basic Commands on Linux You Should Know

For a directory or folder that has a name with spaces you can use backslashes “\” example

cd Command\ Linux

or you can also use single or double quotes (" ‘), use one don’t combine both example

cd "Command Linux"

To return to the previous directory just one step back you can use

cd ..

If two steps back then as follows

cd ../..

Basic Commands on Linux You Should Know

and so on.

Create Directory

Now continue to the part of creating a directory, creating a directory we use mkdir. mkdir is short for make directory example

mkdir CommandDasarLinux

Basic Commands on Linux You Should Know

If you want to create a directory with spaces for example the directory “Command Dasar Linux”, then use the same principle as moving directories, namely with single or double quotes (",’) and backslashes (\) here’s an example.

mkdir Command\ Dasar\ Linux

or

mkdir "Command Dasar Linux"

Basic Commands on Linux You Should Know

You can also create two or more directories directly for example

mkdir dir1 dir2 dir3

Display Directory Contents

After creating a directory with Linux commands then we must be able to see whether the directory was successfully created. Add -a if you want to see hidden files.

ls

Basic Commands on Linux You Should Know

You can also directly include the destination directory, for example

ls "Command Dasar Linux"/

Create and Display Text Contents

To create files and also display text contents from text files we use cat, example to create a new file as follows.

cat> command.txt

then we can fill it with text and when finished we can press CTRL+C

Basic Commands on Linux You Should Know

To display the contents of the text you can use it directly without the > sign

cat command.txt

if writing more than one file then it will display text contents per block

cat command.txt lorem.txt

Basic Commands on Linux You Should Know

combine 2 or more text files with cat

cat file.txt command.txt > gabungan.txt

Basic Commands on Linux You Should Know

Move and Rename Files

Now you already have several files and want to move them then use mv

mv gabungan.txt Command\ Dasar\ Linux/

If renaming files use the command as follows mv oldname newname for example.

mv gabungan.txt baru.txt

Copy File

If you want to create a backup of a file we can use copy with the command cp filename destinationdirectory. This command can be used for files or directories along with their contents. Example application.

cp baru.txt Dir

Delete Files and Directories

Delete directories can use rmdir, but the command cannot delete files and if the directory contains files then you cannot use the rmdir command apparently this is intended as a safeguard if you only want to delete directories and if you want to delete all directories and empty subdirectories add -p to the command all directories and subdirectories can be deleted if there are no files in them. If you want to delete directories, subdirectories and file contents then you can use rm -r, this command can delete files and directories along with their contents. Example usage.

rmdir CommandLinux/

If deleting files and directories containing files

rm -r Command/
rm -r old.txt

Linux Command Line Tips

Use tab when typing commands, for example when typing cd Command then when cd C press tab and automatically the letter C becomes Command, if there are two C for example one “Command” and one “Cubby” then you must type Co then tab if C alone will not work.

Final Words

Actually there are still many basic command lines that must be learned while I usually only use that. Even then it’s still rare, now Linux supports GUI almost completely so for new users the basic Linux commands are enough to use.