Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

7 Linux Commands Every Beginner Should Know

tadashihamada

Recruit
Basic Member
Messages
4
Reaction score
0
Points
16
If you’re new to Linux, using the terminal can be a bit overwhelming. New Linux distributions like Linux Mint have great graphical interfaces, but the heart of Linux is the kernel and that means using the command line.

Even if you are a Windows user, you’ve probably had to open a command prompt window at some point in your life to perform a task. With the latest version of Windows, Windows 10, you can even install the Ubuntu Bash shell in Windows and run Linux commands directly from Windows!

In this article, I’m going to go over some really basic Linux commands that are common across pretty much all distributions of Linux. Since the bash shell is the most popular shell and the one I use also, I’ll be using that syntax for all the commands. Also, I’ll be mentioning some of the most useful arguments for each command, but there are many more which can be found in the man pages.

1. ls (List Contents)

In my opinion, the first command you should know is the ls command. This command lists the contents of the current working directory. If you just type ls and press Enter, you’ll get a very basic listing of files and folders in the current directory.

View attachment 315460

On most Linux distros, directories will be highlighted in a different color like green. Files will usually be the standard color of the shell prompt, which is grey in my case. Without any arguments, ls is kind of boring. If you use -a with ls, you’ll be able to see all hidden files.

View attachment 315461

Anything that starts with a dot is a hidden file or directory. The hidden directories all have a dark blue color, which is kind of hard to see. Another useful argument is the -l option as shown below.

View attachment 315462

This gives you a long listing of files and folders with a lot more information such as permissions, links, user, group, size and last modification date.

2. cd (Change Directory)

Once you can list the contents of a directory, it’s useful to know how to switch to a different directory. By default, you’ll always start in your home directory when you open a bash shell. This is indicated by the tilde symbol (~) in the shell prompt.

The cd command is how you change directories in Linux. There really isn’t a whole lot to learn with cd, but there are a couple of shortcuts. One good is simply typing cd and pressing enter. This will always get you back to the home directory no matter where you are.

View attachment 315463

Also, you can use an absolute path if you want to get into a directory that is not accessible via a relative path. In the example below, I have to use an absolute path starting at the root (/) to get to etc/ssh.

View attachment 315465

3. man (Help Pages)

The man command is probably one of the most useful commands in Linux. Even advanced Linux users can’t remember every argument to a Linux command. The man pages will give you detailed info on all of the different arguments for a command.

View attachment 315466

The syntax is really simple also. It’s just man followed by the command you want to learn about. In the screenshot above, I did a man ls to learn more about the ls command. One useful argument to man is -k, which will allow you to search all commands using a keyword.

View attachment 315467

Above, I searched for the keyword zip and got back all commands that have the word zip in the command name or in the description. It’s a handy way to find commands you may not have otherwise known about.

Along with man, you can use another command called info to get more examples of how to use a command. Just type info command to bring up the info page for that command.

4. touch (Create File)

If you want to quickly create a new file, the easiest way is to use the touch command. In reality, the touch command is used to change the time stamp on a file, but another use is to create a new file.

View attachment 315468

There are many ways to create files in Linux and later on you’ll probably never use touch to create a file, but in the beginning, it comes in very handy.

View attachment 315469

If a file already exists when using the touch command, it simply updates the last access and last modified timestamps for the file as shown above.

5. cat (Concatenate Files & Print)

Another useful command is the cat command. The main function of cat is to concatenate multiple files, but it can also be used to print the contents of a file to standard output (which is the screen).

View attachment 315470

You can use the -n argument to add line numbers to the output. If you use the -b option, it will only add line numbers to lines that are not blank. If you use cat on a file that is longer than the height of your terminal window, only the bottom of the file will be shown. You can pipe the output of cat to the less or the more command to view the contents of a file page by page.

http://10629-presscdn-0-58.pagely.netdna-cdn.com/wp-content/pictures/2017/03/cat-pipe-more.png

6. mkdir (Make Directory)

At some point, you’ll want to create directories to organize your data better and that’s where the mkdir command comes in. You can use relative or absolute paths for creating directories using this command.

http://10629-presscdn-0-58.pagely.netdna-cdn.com/wp-content/pictures/2017/03/linux-mkdir-command.png

In the example above, I’ve created two directories in my home directory using a relative path and an absolute path. If you need to create multiple hierarchical directories at once, you need to use the -p argument.

http://10629-presscdn-0-58.pagely.netdna-cdn.com/wp-content/pictures/2017/03/mkdir-p-arugment.png

In the above example, I used the -p argument to create the Aseem, Data and Pictures directories all at once even though none of them existed.

7. rm (Remove)

The rm command is a powerful command that can be used to remove files and directories. The rm command can remove directories that have files and directories inside of them.

http://10629-presscdn-0-58.pagely.netdna-cdn.com/wp-content/pictures/2017/03/linux-rm-command.png

To remove a file, you just type in the file name. If you need to remove a directory that is not empty, you need to use the -r argument. It’s also a good idea to use the -i and -v arguments when using rm as it will ask you before deleting anything.

http://10629-presscdn-0-58.pagely.n...ent/pictures/2017/03/rm-command-arugments.png

So those are seven really simple, yet common commands that you’ll need to know in Linux to get started. There are many more and I’ll be posting more beginner articles soon on more commands and how to use them.
 

Attachments

  • linux-ls-command.png
    linux-ls-command.png
    3.2 KB · Views: 97
  • ls-hidden-files.png
    ls-hidden-files.png
    4.7 KB · Views: 63
  • ls-long-listing.png
    ls-long-listing.png
    4.9 KB · Views: 59
  • cd-home-directory.png
    cd-home-directory.png
    2.9 KB · Views: 43
  • cd-absolute-path.png
    cd-absolute-path.png
    4.2 KB · Views: 31
  • ls-man-page.png
    ls-man-page.png
    8.2 KB · Views: 39
  • man-apropos.png
    man-apropos.png
    9.2 KB · Views: 33
  • linux-touch-command.png
    linux-touch-command.png
    4 KB · Views: 36
  • touch-update-timestamp.png
    touch-update-timestamp.png
    9.7 KB · Views: 31
  • linux-cat-command.png
    linux-cat-command.png
    7 KB · Views: 33
Back
Top Bottom