Introduction to Linux Terminal

Introduction to Linux Terminal

Hey!
Ever thought of a computer without a mouse or a touchpad? No? If no? Then why? Is there a way to operate a computer without that small sweet little device called mouse? Hmm… topic for me seems to be very interesting indeed!

The mouse was really a next level invention using which any New user can easily give commands to that Operating System, to carry out the user’s required task. But a mouse is a learning utility using which operating on a GUI become more feasible for a newcomer.

But you, are not a Newbie ( that’s why you are reading this article ), right? Then let’s take a step forward towards a more professional approach to operating a computer system without a mouse. Learning which, you would be able to operate a Linux operated computer with merely thy Keyboard and believe me, once you would be comfortable with command line terminal, You would be able to operate your machine more easily than a mouse. Then without wasting a second, Let’s go to Linux Terminal.

Open your Linux Distribution ( Mint, Fedora, Ubuntu (my favorite ) ). and press

Alt + Ctrl + T-> to open your Linux terminal

Have you opened it? Right. Nicely done [ if you did it : ) ] something like this will be shown

Let's go with linux terminal

This is Terminal! You can do a lot of fascinating stuff using this. Moving on. Here ‘@’ divides a statement in two-part i) “coderunner” (here) this is your username & ii) “geekyshacklebolt” (here) this is your hostname. Followed by the Symbol “~” is called “strudel” this symbolizes your home directory. Followed by “$” symbol after which you can write terminal “commands”.

Another : Alt + Ctrl + T -> will open another new terminal in a separate window (by default). However you may change the settings by maximizing your terminal -> edit (option at menu bar) -> preferences -> “open new terminal in [window] switch it to [tab].

Now if, Alt + Ctrl + T -> will open another new terminal in a separate Tab in the same window. You may switch between them by, Alt + No_of _tab you want to switch to.

To exit from the terminal type command:

exit

to know more about any command you are going to learn in this blog type command:

man <command>         –“man” stands for manual <command> is any valid command

e.i :-  man man                 — will give you manual about man command.

Here is the list of some widely used Linux Commands with their syntax:- Have a nice learning. And…

If you would face any problem in these commands of the list feel free to ask me via comment or a direct question to me via my contact page.

  1. cd directory_name — “cd” stands for change directory. This command will take you to any directory path you would write.
    e.i cd Public/Newfolder will take your terminal control on Newfolder that is available in Public Folder.

  2. cd ..               — this will take you to the parent directory of the current directory.

  3. cd -                 — this will take you to the directory from where you have come.

  4. cd /                 — this will take you in the root directory.

  5. ​pwd        — “pwd” stands for “print working directory” as the name suggest this will print the current directory you are in.

  6. ls             — “ls” stands for “listing” this will list the folders and files available in the current directory.

  7. ls -a        — attribute ‘a’ is added after ls which extends its purpose. Now “ls” can show you “all” the files and folders irrespective of their hidden mode.

  8. ls -al        — attribute ‘a’ and ‘l’ is added after “ls”. Now “ls” will list “all” the files and folders in “long format”.

  9. cal               — will give you simple calendar.

  10. uptime       — will give you the system uptime. And current time too.

  11. cp                 — “cp” stands for “copy”.
    Syntax: cp <source> -t <target>   —
    e.i: cp *.* -t ~/Public   — this will copy all the files of your current dir. To home/Public.

  12. mv           — “mv” stands for “move”.
    Syntax: mv <source> -t <target>. syntax similar to “cp”

    * you can also use mv for renaming like
    e.i: – mv oldfile newfile — this will cut oldfile and paste it with new name newfile in the same directory. Works as renaming.

  13. gnome-open           — to open a directory in GUI.
    e.i :- gnome-open .      — here “.” dot means this current directory. So, this command will open your current dir. In GUI.

  14. touch   — to create single and multiple empty files.
    e.i:- touch file1 file2 file3 … fileN 
    — this will create all these files whose names are given.

  15. nano    — “nano” is a built-in terminal based text-editor comes with Linux. You can open files in nano for editing.
    e.i:- nano file_name      — this will open the file in nano editor.

  16. whoami       — will give your user name.

  17. cat                 — will give you the content of a file.
    e.i:- cat file_name       — will list the text in this file “file_name”

  18. grep              — will search a pattern in a file.
    e.i:- grep “my name” newfile       — now if any line in the file “newfile” will be containing the given pattern (my name: in this case) it will search out and will be displayed to you.

  19. more            — now suppose you are opening a very large file. Using cat.
    e.i:- cat very_long_file — terminal will show you all the content of the file and by default will take you to the end of the file within a second. In this case, if you want to access the “very long file” page wise from the beginning. You may
    use:- cat very_long_file | more

  20. less                    — above result may be obtained without cat and | more, by using just “less” command.
    e.i:- less very_long_file

  21. sudo                 — to give administrative permission to a command. This is generally used while you install a software or package.
    e.i:- sudo apt-get install <package_name>

It will ask you for your admin. Password and your work will carry out.

  1. find              — use to find a file in a directory. Syntax:- find ~/Public/Newfolder -name file_name           — will find you file in you given path.

  2. locate          — also use to find a file. e.i:- locate myfile.py — will locate myfile.py path from the complete file system.

  3. which          — syntax:- which <command>         — will give you the path where you command is present.

  4. useradd           — use to add a new user. Syntax:- sudo useradd username

  5. userdel            — use to delete any existing user:- sudo userdel username

  6. groupadd       — use to add a new group:- sudo groupadd groupname

  7. groupdel         — use to delete any existing group:- sudo groupdel groupname

  8. firefox             — will open your Firefox browser. Also e.i:- firefox google.com — will open the browser and go the website you gave it as an attribute ( google.com in this case)

  9. blkid                — will list all available file system:- sudo blkid

  10. rm                    — use to remove a file :- e.i:- rm newfile           — will delete “newfile”

  11. mkdir             — use to create new folder. mkdir stands for “make directory”. e.i:- mkdir folder_name     *also if you want to create multiple parent child to child folder like a/b/c/d then you may use:- mkdir -p a/b/c/d          — attribute ‘p’ stands for parent.

  12. rmdir              — use to remove empty folder/directory. rmdir stands for “remove directory”. e.i:- rmdir dir_name_or_complete_path. As rmdir newfolder/newfolder2  — will remove “newfolder2”

  13. rm -rf               — use to remove non empty folder/directory. Attributes ‘-r’ stands for ‘recursive’ and ‘-f’ stands for ‘forcefully’ without asking by permissions again and again.

* never use :- rm -rf / — this will delete your root and operating system will destruct itself. So, handle “rm” commands with care.

  1. clear                          — use to clear the terminal screen. Or you may press “Ctrl + l”.

  1. apt-get install       — will install the package. e.i:- sudo apt-get install <package_name>

  2. apt-get update       — will update softwares on your Linux. (both need Internet connection)

  3. updatedb                 — update your machine’s database. (by default this process run on schedule)

  4. hostname                — will give you your hostname

  5. users                          — will give you the names of logged in users

  6. gedit <filename>                       — will open a file in gedit- it’s a GUI simple text editor.

  7. man -k “function”                    — suppose you don’t know about the commands used for searching or to delete or any other “function” then you can’t make the use of that simple “man” command. You need to modify it by using ‘-k’ attribute.

    e.i:- man -k search    — will lists all the commands use for searching

  8. history                          — will give history of the commands (number vice) you have entered so far.

  9. !no_of_command      — use to run a command by number represented by history command.

  10. shutdown now          — use to shut down your PC “now” other alteration of these commands are also available but:-

  11. TabCompletion –typing directory’s complete name is time consuming task, you can simplify this task by TabCompletion. Type just 2-3 letter of your directory then press <tab>, terminal is smart enough it will fill the rest of the path of its own.

    But if more than one file is present with that same letter than you need to press <tab> twice, it will show you all the possibilities of your matching letter then you may type the rest of the name.

  12. etc.,,etc,,, there are a lot of commands more like pushd, popd, other shell commands, permissions/mode commands, etc.

Explaining all commands of Linux is out of reach of this blog. I am leaving here, rest your curiosity and Internet will lead you through.

If you further want to clear your basics. Go with this Crash Course of Terminal: Here!

Have a fantastic journey and healthy learning and This, is GeekyShacklebolt

bidding you goodbye!

Advertisements

2 thoughts on “Introduction to Linux Terminal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s