Filed and Directory Commands Flashcards
ls -al
List all files in a long listing (detailed) format
pwd
Display the present working directory
mkdir directory
Create directory “directory”
rm file
Remove (delete) file
rm -r directory
Remove the directory and its contents recursively
rm -f file
Force removal of file without prompting for confirmation (-f is Force)
rm -rf directory
Forcefully remove directory recursively
cp file1 file2
Copy file1 to file2
cp -r source_directory destination
Copy “source_directory” recursively to “destination”. If “destination” doesn’t already exist, create “destination” with the contents of “source_directory”
mv file1 file2
Rename of move file1 to file2. If file2 is an existing directory, move file1 into directory file2
ln -s /path/to/file linkname
Create symbolic link to “linkname” (from /path/to/file)
touch file
Create an empty file or update the access and modification times of “file”
cat file
View the contents of “file”
less file
Browse through a text file
Why “less”?
head file
Display the first 10 lines of “file”