Basic Linux Commands
Almost all Linux/Unix commands have extra switches (options) that can be used to customize the way a command works. To learn how a command works and the possible options for using the command, type "man <command>" at the Linux shell prompt or search the Internet for "man pages <command>". For example, at the command prompt, you could type "man cd" (don't type the quotes) to learn more about how to use the "cd" command.
Exploring Directories and the File System
/ (a slash) - represents the top (or root) directory of the file system.
.. (two periods) - represents the parent directory (the directory just above the current directory).
. (a single period) - represents the current directory.
pwd - Print the name of the current directory.
cd - Change directory.
cd /- Change to the root/top directory.
ls - List files in current directory.
cd ..- Change to the directory one level above the current directory.
ls- Display basic directory listing.
mkdir - Make/create new directory.
ls -al- Display directory with hidden files (those that start with a dot) in long format (owner, permission, size, timestamp).
rmdir - Removes an empty directory.
mkdir temp- Creates the directory named "temp" inside the current directory.
rmdir temp- Removes the directory named "temp" inside the current directory.
df - Displays the available disk space on each file system.
rmdir -rf temp- Removes the directory named "temp" even if it contains files - be careful!
Working with Files
cp - Copy File.
cp file.txt new_name.txt- Makes a copy of "file.txt" and names the copy (in the same directory) "new_name.txt".
mv - Move (or Rename) File.
cp file.txt /home/bob/- Copies "file.txt" in the current directory and makes a copy and stores it in the /home/bob/ directory.
mv file.txt new_name.txt- Renames the file from "file.txt" to "new_name.txt".
rm - Remove (delete) File.
mv file.txt /home/bob/- Moves "file.txt" in the current directory to the /home/bob/ directory.
cat - Displays the contents of a file on standard output (usually the screen unless you direct it [pipe it] somewhere else).
rm file.txt- Deletes the file named "file.txt".
more - Displays the contents of a file or stream one page at a time. Useful for long files or data. Use space bar to view next page or Enter key to see one line at a time.
cat file.txt- Displays the contents of the file named "file.txt".
more file.txt- Displays contents of the file from "file.txt".
less - Displays the contents of a file like "" except you can page up and down.
ls -al|more- This would display all the files in a directory, one page at a time.
chmod - Change the permissions (read, write, execute) of a file.
less file.txt- Displays the contents of the file named "file.txt".
chmod 775 file.txt- Gives read, write and execute permissions to User and Group and read and execute to all others.
chmod ug+rwx,o=rx file.txt- Same as above command, but uses an alternate method of setting permissions.