What is a terminal? How to I open a terminal? Why do I need to learn the command line anyway? I’m guessing that many of you hear this too. And the fact that if you choose your Linux distribution with a little care, you need never open a Terminal window in your life. Or Maybe there are myths, if someone sat and actually spent ten minutes typing in commands, they might actually be able to see past a screen full of code.
However, in realistic world often the Terminal is the quickest way to get a job done efficiently. If you are in the Gnome desktop environment with no mouse, then hit Alt-f2 and type gnome-terminal. Gnome has a gnome-terminal and KDE has Konsole. Most Linux distributions supply several, such as: xterm, rxvt, konsole, kvt, gnome-terminal, nxterm, and eterm.
Command is typed first with no spaces in the name. Then after a space, you can sometimes modify the command by adding what are called options. Options change or limit the way the command is executed. Options are usually preceeded by a dash. A command may also include the name of a file or directory that you want the command to work on. The command will look something like this.
$ command -option file
Open a terminal and then type whoami:
(It should return your login name. The word that you just typed is a command. The computer executed the command and returned a result, your username.)
The command ls stands for list.
(It will list all of the files and folders inside)
$ ls -alp
(The option -a showed you all of your files. The -p option helps you tell the difference between a file and a directory by writing a slash beside each directory. The -l option will print a table of your files that describes not only the name, but the size, the date created, the permissions, and who owns the file.)
$ whatis firefox
(Look up what a command do. One of the simplest ways is to use the command whatis. Try typing whatis and the name of the command in question.)
$ man ls
(man and a command name and a page will open up giving you lots of information about that command written in paragraph form. man stands for manual. After finish viewing it, just hit the letter Q (quit) to exit.)
(To find your current location type the pwd command, pwd stands for “print working directory”.)
$ cd /home/jonboy60
(You can navigate around the file system using the cd (change directory) command. Type cd followed by the name of the the directory that you wish to go to.)
$ cd ../
(Go up to the next higher directory, you type cd ../ the letters “cd” followed by a space and then dot-dot).
Command which makes a copy of file1 in the current working directory and calls it file2.
$ cp file1 file2
Copy file1 to the another directory.
$ cp file1 /home/jonboy60
Extra tips click here.
Moves (or renames) file1 to file2
$ mv file1 file2
To delete (remove) a file, use the rm command.
$ rm jonboy60.jpg
Create a directory called tempstuff using mkdir
$ mkdir tempstuff
Remove it using the rmdir command.
$ rmdir tempstuff
Display the contents of a file on the screen.
$ cat jonboy60.txt
Search a file for keywords, grep -i “search word” “file”.
$ grep -i comp jonboy60.txt
Searches through the directories for files and directories. find “directory” -name “filename”.
$ find . -name “*.txt”
Alternative command by using locate.
Chmod, change files or folders permission.
$ chmod 755 jonboy60.txt
More details click here.
The df command allows you to select which file systems to display.
$ df -i
$ df -h
You can kill programs that hang up your system.
$ killall -9 firefox
More info click here
You can view the history of the last several commands that you have typed by pressing up down arrow on your keyboard. Once you learn the language, a whole new world is open to you. Language is still the powerful tool. When you learn to talk the language that your computer understands, there is no middle man. Try it and in time you too may learn to love the command line.