Linux: File Operations Cheat Sheet

# List all files in a long listing (detailed) format

ls -al

# Display the present working directory

pwd

# Create a directory

mkdir directory

# Create file1

touch file1

# Concat­enate files and output

cat file1 file2

# View and paginate file1

less file1

# Get type of file1

file file1

# Remove/ delete file

rm file

# Remove the directory and its contents recursively

rm -r directory

# Force removal of file without prompting for confirmation

rm -f file

# Forcefully remove directory recursively

rm -rf directory

# Copy file1 to file2

cp file1 file2

# Rename or move file1 to file2

mv file1 file2

# Create symbolic link to linkname

ln -s /path/to/file linkname

# Create an empty file or update the access and modification times of file1.

touch file1

# Show first 10 lines of file1

head file1

# Show last 10 lines of file1

tail file1

# Output last lines of file1 as it changes

tail -F file1

Leave a Reply

Your email address will not be published. Required fields are marked *