Quantcast

Don't have an account? Register Now! Forgot password?

Maximum IT
Features

The Beginner's Guide to Linux Part 4: Introduction to the Terminal

comment Commentsprint Printemail EmailDeliciousDiggStumbleUponRedditFacebookSlashdot

Essential basic commands

Although there are hundreds of commands available for the terminal, the following table will introduce you to the most essential ones. Any portions of a command enclosed in < > brackets is a variable and should be replaced with what is specified between the brackets. For example, < file> indicates that a file should be designated.

Essential Terminal Commands

Command Function Usage
ls Lists all files in a directory “ls” (Use “ls -l” for detailed output) For those used to DOS or cmd.exe, “dir” is very similar.
cp Copies a file or folder “cp <source file/folder> <destination file/folder>” e.g. “cp file1 file2” or “cp folder1 folder2” The first file/folder in the command is the original file while the second one is the file/folder that will be created as a copy.
mv Moves a file from one directory to another. Also works as a rename command “mv </folder/file> </newfolder/file>” or “mv file1 file2” (this will rename file1 to file2)
cd Change to a different directory “cd <new directory>” Only a folder name is needed instead of a full path if the new directory is a sub-directory of the current folder. To move to the next highest directory, run “cd ..”
mkdir Makes a new directory in the current folder “mkdir <new directory name>”
rm Removes a file or directory “rm <file>” removes a file. To remove a directory, use “rm -r <directory>” . Beware of “rm -rf /”, as this command will delete everything if executed as root.
chmod Changes file properties Chmod assigns file properties based on numbers and letters. Using + will add a new property, while – will take it away. For example, “chmod +x <filename>” will make a file (like a shell script) executable. For a list of file properties, run “info chmod”.
chown Changes ownership of a file or folder “chown <owner>:<group>   <file>” <owner> and <group> should be set to the new owner and group.
man Shows a manual page that tells you how to use a program  “man <program name>” Sometimes, there is an “info <program name>” as well.
top Shows real-time process information and system usage stats “top” To exit top, press Q.
cat Concatenation tool used to join plain text files together “cat <file1> <file2>” Cat is often used to preview individual files, but this is not really what it is for. (use less instead)
ps Shows process information for a user “ps -u <user>” e.g. “ps -u root” Sort of like top, but good for when you don't want or need real-time info. This command is best used with a grep pipeline to help you find a specific process.
kill Forcefully terminates a process “kill <process ID>” The process ID of the program you want to kill can be determined by running ps or top as shown above. If a program will not terminate with the normal kill command, “kill -9 <process ID>” will stop it for sure.
sudo Executes command as superuser/root “sudo <program>”
su Escalates to a root shell “su”
less View an individual text file “less <filename>” The up and down arrows allow you to scroll through the file. To return to the shell, press Q. Use this tool instead of cat when you want to look for individual files.
Grep Searches for a text string Grep is frequently used in pipelines, but “grep <pattern> <file>” can also be used to search for keywords in files.

 

 

 

COMMENTS
avatarWhy?

Why? Isn't it easier to just click on an icon on the desktop? Why would any sane person want to do it the hard way?

These are the InterWebs? Where's the bicycles, babes and beer?

Login or register to post comments
avatarSweet Jeebus... thats a lot.

Well, practice, practice, practice. Thanks.

Login or register to post comments

This Month's Issue
FEATURE How to Get FREE Programs, Services, Software & MoreFEATURE Digital Photo Printer RoundupHOW TOBuild a 3D CameraFEATUREDIY Arcade PCWHITE PAPERHow TRIM Works