Linux can be daunting to some, especially if you have seen people working only through the terminal. Trust me, its not as complicated as it seems neither is it that hard to learn. The only issue is manufacturers do not Linux with their systems.

What is Linux?

The entire family of Unix like open-source operating systems that are based on Linux Kernel is Linux. Linux distros include : CentOS, Ubuntu, Fedora, Mint, Debian and a lot many.

First released in 1991, Linux has been the back bone of just about every infrastructure. Since it is open-source, it can be modified and redistributed as your liking.

Linux uses a shell, basically an interface that gives you access to the operating system’s services. Don’t its not always this daunting, there are a great many Linux with fabulous GUIs.

Be that as it may, it is recommended to use the command-line interface (CLI) because it’s more powerful and effective. One line commands that are powerful enough to complete something that will take minutes on GUIs in seconds.

Thus if you are interested in learning here are 10 most basic commands that you should definitely know.

Linux Basic Commands

Here is a list of basic Linux commands:

1. pwd command

While on a command line interface you might find yourself getting lost, where are you? Which directory did have you been working in?

Just write ‘pwd’ on your terminal and press enter, it will give you the absolute(full) path.

pwd

2. cd command

Basic navigation command to move in and out of linux directories.

Absolute path

Lets say we have to go inside /root/Downloads

No matter where you are currently, just type

cd /root/Downloads/

Relative Path

Now lets say there is another folder inside Download, “movies”.

If you are already in /root/Downloads

Just type

cd movies

Then you will find yourself inside, /root/Downloads/movies

Do a quick pwd to confirm 😊

Back trace

In order to move up a directory, type in

cd ..

This will move you up one directory

Going by previous example you should be in /root/Downloads now

There are some shortcuts to help you navigate quickly:

  • cd .. (with two dots) to move one directory up
  • cd to go straight to the home folder
  • cd- (with a hyphen) to move to your previous directory

On a side note, Linux’s shell is case sensitive. So, you have to type the name’s directory exactly as it is.

3. ls command

On a GUI windows you can see what is inside a folder, but on a command line tool, you will need to list all the contents.

Do it by typing in

ls

There are variations you can use with the ls command:

  • ls -R will list all the files in the sub-directories as well
  • ls -a will show the hidden files
  • ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.

4. cat command

If you want to quickly read what is inside a file on the command line itself, use cat.

cat (short for concatenate) is used to list the contents of a file on the standard output (sdout). To run this command, type cat followed by the file’s name and its extension. For instance: cat file.txt.

Here are other ways to use the cat command:

  • cat > filename creates a new file
  • cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
  • to convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt

5. cp command

This I will agree with you, copying is not as easy as it would be on a GUI, but once you get a hang of it, its better I guess.

Use the cp command to copy files from the current directory to a different directory.

For instance, the command cp <filename> /<directory to copy> 

This would copy the grafana-7.1.1-1.x86_64.rpm to the tmp folder.

6. mv command

Now move has two purposes in everyday usage. First is to move files,duh!

Second is to rename files.

The arguments are similar to the copy command, as you can look at it as copying the file and removing the original file from its place.

The primary use of the mv command is to move files, although it can also be used to rename files.

The arguments in mv are similar to the cp command. You need to type mv, the file’s name, and the destination’s directory.

For example: mv <filename> /<directory to move>

This will move the file grafana-7.1.1-1.x86_64.rpm to the etc folder.

Renaming

To rename files, the Linux command is mv oldname.ext newname.ext

7. mkdir command

Use mkdir command to make a new directory — if you type mkdir Download it will create a directory called Music.

There are extra mkdir commands as well:

  • To generate a new directory inside another directory, use this Linux basic command mkdir Download/Newfile
  • use the (parents) option to create a directory in between two existing directories. For example, mkdir -p Download/mid/Newfile will create the new “mid” file.

8. rmdir command

If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.

9. rm command

The rm command is used to delete directories and the contents within them. If you only want to delete the directory — as an alternative to rmdir — use rm -r.

Note: Be very careful with this command and double-check which directory you are in. This will delete everything and there is no undo.

10. sudo command

sudo means “superuser do”, this means that you are the chosen one foe the system. You can install remove softwares, change permissions, create other users and just about do everything on the system that a normal user might not.

To Sum Up

This was only a short collection of Linux commands for newbies to get started with the terminal. I will publish more commands and help you get acquinted with the terminal better.

Until then, Cheers! See you in the next one.

Categories: Knowledgebase

0 Comments

Leave a Reply

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

%d bloggers like this: