Today In Terminal: Love thy CLI , Basic Terminal Commands for New Users

terminal

Today I will be going over the basic Terminal commands a new user should know.  In case you are unaware the Terminal can be accessed via Applications > Accessories > Terminal.  Think of the Terminal as a beefed up and much more robust DOS Prompt or Command Prompt.  The Terminal itself is merely an “emulator” of the BASH shell, or bourne again shell.  It is an app that interprets the parameters of the BASH shell.

The first and most important thing to know is how to navigate your terminal :

“cd” 

  • cd will change directory.  For example if we wanted to change to the /home/user directory, or the users “home” directory we would type “cd /home/user”. Also, “cd ..” will change directory up one level. 

“ls” 

  • ls  will list the available files/folders in any directory you are in.  Good to know options for ls are : “ls -a” , which will show all files (including hidden), and ls -la, which combines the best of both worlds and provides a long listing (easier to read) of all available files.

“pwd”

  • pwd will output the current directory you are in to the Terminal screen.

“File FILENAME

  • This command will list the details of any file.

“cat FILENAME” 

  • This will concatenate a file and output to the screen.  For example if I were to “cat /home/user/file.txt” it would output the contents of that file to the screen.

“less FILENAME

  • Less is a more powerful command than the “More” command which is very similar in nature.  Does sort of the opposite to cat, where instead of outputting to the Terminal screen, outputs to a blank screen.  Press q to quit here.

“man COMMAND_NAME” 

  • The man command is especially use full if you do not know how to use a particular  command of application.  For instance “man apt-get” in Ubuntu will display all the relative help and details for that command.

Piping a command with “|”

  • the vertical line (Ctrl + Backspace) will pipe and output.  For instance, “man grep | less”  will pipe the man page of grep to less

“find”

  • find will search for files.  For instance, “find temp”while in a users /home/user or “home” directory, will search for anything named “temp.”  You can also specify a path if you want to find  in another directory.  For instance, “find /home/user/programs/VMware” will try to find “VMware.”

“grep”

  • grep will grab the output you specify.   For instance, “find /home/mikeyd/| grep temp”  will search my home directory , and grep any entries that have temp in the path name

“clear”

  • This command will clear the screen

Up or Down on Keyboard

  • Pressing up or down on the keyboard will show the previous or , if you went back a few commands, down will show you the next command.

“cp” 

  •  cp will copy a file or folder.  You may have to put “sudo” in front of the command if that file or folder is protected.  For a file the syntax would be “cp /path/file.txt /home/user” where the file.txt is being copied to “/home/user”, which is a folder.  For Folder copying, the syntax is “cp -Rv /path/folder /home/user” where R option means recursive (all files and folders underneath that directory if you wish), v option for “verbose” (outputs whats its doing for each file copied), and the folder is being copied again to the “/home/user directory”

“rm” 

  • rm will remove a file or folder COMPLETELY from the system.  If you wish to recover it later, drag that file he trash on your bottom panel (far right).  Syntax is as follows “rm /home/user/temp.txt” for a file or “rm -Rv”  for a folder.  You may have to put sudoinfront of the command .  Be very* cautious while using rm

mkdir”

  • mkdir will create a directory.  Syntax is “mkdir /home/user/new_directory” where this creates a “new_directory” in the users’s “/home/user” directory.  If you wish to make a folder in the current directory, simple do “mkdir new_directory”  You may need to put sudo  in front of mkdir if it is a protected directory.

That’s it for today.  Hope these commands help you in you Linux endeavors.  Take it easy at first, while it may be intimidating to use the terminal, it is your best friend 🙂

Cheers!

_Nano

Advertisements

About professorkaos64

www.libregeek.org

Posted on 20090320, in Basics, How-To, Terminal and tagged , , , , . Bookmark the permalink. 1 Comment.

  1. Actually,good post. thx

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s