pwd - shows path to the current location. For more information, click the command.
cd - changes current directory to the one specified with the command. For example,
cd temp will take you from the current directory to temp directory and
cd .. will take you back to the parent directory.
man is a very helpful utility that displays help on pretty much any linux command.
Syntax:
man ls will display help on using the listing -
ls command. To get out of man, type
q (quit)
ls - listing - outputs list of files and directories at the specified path and of specified pattern, such as:
ls a*.sh will list all files that begin with "a" and end with ".sh".
One of the most frequently used options of the ls command is
-l. When used with ls, the output shows permissions on the file, such as "-rwxrw-r--", and some other information.
For more information on use of
ls click on it.
cp - copy - copies files from one location to another.
Syntax:
cp source destination, e.g.
cp file1 myfiles/file1
For more information on use of
cp click on it.
mv - move - moves and/or renames files. Unlike moving a file within windows folder structure, linux mv command can also be used as "rename" or "move and rename" equivalent.
For more information on use of
mv click on it.
diff - find differences between two files - compares contents of two files and either returns a message if the files are different or displays the actual differences - depending on the options specified. There are many options that can be specified with this command.
Example:
-bash-3.2$ diff --brief <(sort file1) <(sort file2)
Files /dev/fd/63 and /dev/fd/62 differ
-bash-3.2$
For more information on how to use
diff, click on it.
chmod - change mode - changes permissions for groups, owner, and others for a specific file. For example, to give access to file myfile.sh, type
chmod 777 myfile.sh. Once this command finishes running, everybody will be allowed to edit and execute
myfile.sh.
For more information, click on the command.
fgrep - searches contents of one file or multiple files for a specific pattern. For example, to search all files in the current folder for the word 'hello', type this:
fgrep 'hello' *. This command will find all instances of word 'hello' in all the files within the current directory, but it will skip 'Hello', 'HELLO', and any other variation of it that has capitalized letters. To capture all of those instances, type the following:
fgrep -i 'hello' *.
vi - opens the vi editor. To create a new file, type:
vi newfilename; you can also just open the vi editor without specifying a new filename; this can be done when saving the new file:
w newfilename. To edit an existing file, type
vi existingfilename. For vi commands, see
my post from april 2012.
cat - short for concatenate. Click the command to see more info on cat command.
echo - same as in DOS - outputs the text to the terminal. For example,
echo "Hello World" will output the string
Hello World.