How-To Guides and Blog

Basic Linux Commands Every Beginner Should Know

NBH Support
No Comments

If you’re a long-time Windows user, new to Linux, using the terminal may feel like alien territory.

After all, you’re probably more accustomed to being able to point here, click there to get things done.

And, while some Linux distributions like Mint have a user friendly graphical interface, the core of Linux is the kernel, which means you’ll want to access the command line occasionally to fully customize your user experience.

Here are some of the most useful basic Linux commands you’ll want to know to comfortably navigate the command line.

cd – Change directory

You can use the cd command to change the directory you are to another directory. Let’s say you are currently in folder1 which is located to /home/user/Desktop/folder1 and want to go to folder2 which is located in the same location. To do that simply type cd and the location of folder you want to browse, in this case you are already on folder1, so to go folder 2 you need to type cd /home/user/Desktop/folder2.

Another way could be via cd .. command, this command will take you back to desktop, so to access folder2 you need to type only cd folder2.

cd /home/user/Desktop/folder2

cd-command

touch – Touch

The touch command allows you to create empty files. For Example: The command "touch ebblr.txt" will create an empty txt file called ebblr.

touch-ebblr

ls – List

ls

ls will list all the files and directories of the current directory you are in.

ls-command

w – Logged in users

W command will print the information about users who are currently logged in.

w

w-command

whoami – Who am i

Whoami prints the username of the owner of the current session.

whoami

whoami-command

mkdir – Make Directory

Use mkdir to create a directory. Type mkdir and the name you want to use for the directory that you are creating.

Example : mkdir myfolder, will create a folder called myfolder.

mkdir myfolder

mkdir

rmdir – Remove Directory

rmdir is the opposite of mkdir, mkdir will create a folder, rmdir will delete it. So, to delete a folder you need to type rmdir and the location of folder that you want to delete.

rmdir /home/user/Desktop/folder1, will delete the folder called folder1.

Remember, rmdir will not delete a folder if it’s not empty. Use the following instead

sudo rm -rf /home/user/Desktop/folder1
rmdir /home/user/Desktop/folder1

rmdir-command

cp – Copy

Use cp command to copy a file from a directory to another. For example : We are going to copy song1.mp3 which is located on /home/user/music/song1.mp3 to a subdirectory on music folder, called newmusic. To do that, you need to type the following

sudo cp /home/user/music/song1.mp3 /home/user/music/newmusic

cp-command

mv – Move

move

mv command allows you to move a file to a directory. Let’s say we want to move file.txt to a directory located on desktop. To do this, type mv file.txt /home/user/Desktop/.

mv file.txt /home/user/Desktop/

mv-command

pwd – Print Working Directory

pwd

Pwd will print the working directory you are currently. Pwd is very useful command, specially when you are browsing through a lot of directories and want to know the full path.

pwd-command

That means, you are currently on /home/username

history – Show history

history

History it’s another very useful command. The main function of this command is to print all the commands that you’ve used on terminal.

history-command

clear – Clears the Terminal Screen

clear

Clear will clear your terminal screen.

clear-command

uptime – Shows uptime

uptime

Uptime is a command that will show you how long your system has been up.

uptime-command

date – Shows date

date

Date prints the current time and date of your system.

date-command

man – manual

Short for ‘manual’, provides useful and detailed information for any other Linux command you specify. Think of it as a help page.

man intro is a good place to start if you’re new to Linux with an introduction to User Commands and the Linux command line.

When typing a command, just press TAB for auto-complete.

intro-command