This command will show you the contents of a directory.
ls --> will show you the contents of the current directory.
ls /dir/name --> will show you the contents of a specified directory.
ls -l --> will show you a long listing containing ownership, permissions, time last modified, and size.
ls -a --> will show you all of the files in the directory, including . (dot , the current directory)
ls -al --> What do you think?
Note that . stands for the current directory and .. refers to the parent directory
cd (Change Directory)
This command will change your current working directory.
cd --> If you just type in cd, then you will be sent to your home directory. For example, /home/mlevan/
cd /dir/name --> This command will send you directly into the desired directory.
cd /var/log/ --> This will send us to the /var/log directory.
What about these commands :
cp filename1 filename2 this command will copy the first file into the second file
cp Amy.txt Garret.txt
Note that if Garret.txt is already a file, then it will be overwritten !! Be careful with this command.
cp -i Amy.txt Garret.txt
If Garret.txt exists, then this command will inquire if you want to overwrite the file.
If Garret.txt does not exist, then you will not be asked.
Note that you can also add directory names to this:
cp /home/mlevan/Amy.txt /home/guest/Garret.txt
You can also copy files to a directory :
cp file1 file2 fileN directory_name
cp Amy.txt Garret.txt temp/
Note that ~ can also represent your home directory. For example, say I want to copy a file from /home/guest1/booty to the temp directory in my account:
cp /home/guest1/booty/blah.txt ~/temp/
The rm command will remove a file.
If you type in rm -i filename , then you will be asked if you really want to remove the file.
It is virtually impossible to regain a file after it has been removed in this fashion.
This is the "rename" command used in DOS.
This command moves one filename into another filename.
mv filename1 filename2
The above command automatically writes over filename2 with whatever was in filename1
mv -i filename1 filename2
The above command will inquire if you really want to move the file.
You can also move directories with this command,
mv dir_name1 dir_name2
This command will create a file.
If the file already exists, then touch will update the timestamp of the file.
mkdir (MaKe DIRectory)
This command will create a directory in your current working directory:
You can create a directory anywhere using the full pathname... if you have permission:
rmdir (ReMove DIRectory)
This command will remove an empty directory.
If the directory is not empty, then pass the parameters r (recursive) and f (force) to the rm command.
The f parameter will force the removal, never inquiring if you want to remove any subsequent files or directories.
The r parameter will remove travel down any directories within the directory and remove all the files.
rm -rf dir_name
This command will print out a text file.
What happens if we pass two files to this command?
cat filename1 filename2
What happens if we don't pass any files to this command?
Control-D or Control-C ?
Control-C terminates a program.
Control-D stops the current input. (Admittedly, this can also end a program)
(source: bootThe Joy of Penguins - thanks a lots)