Language: EN


Linux Commands - File and Directory Operations

Here is a compilation of the most useful Linux commands for File and Directory Operations

In commands that require entering file or directory names, you can press tab twice to autocomplete the path, or obtain a list of available files.

# go to root directory

# go to previous directory
cd ..

# enter directory (absolute path)
cd /directory1/directory

# enter directory (relative path)
cd directory1/directory2

# go to user directory
cd ~

# go to last visited directory
cd -

# show current path

List files and directories

# show files and directories

# show files and directories with details
ls -l

# show files and directories, including hidden ones
ls -a

File and directory manipulation

# rename or move a file or directory
mv source destination

# copy a file
cp file destination

# copy a directory
cp -r source destination

# delete the file named file
rm file

# delete directory if empty
rm -d directory

# delete directory and its contents
rm -r directory

# create new directory
mkdir directory

# create multiple directories simultaneously
mkdir directory1 directory2

# create directory path
mkdir -p /directory1/directory2

# create empty file
touch file

# change file date (year, month, day, and hour format)
touch -t 19901230000 file

# create a symbolic link to the file or directory
ln -s file link1

# create a physical link to the file or directory
ln file link1


# calculate the md5 checksum of a file
md5sum file

# encode file using GNU Privacy Guard
gpg -c

# decode file using GNU Privacy Guard
gpg file.gpg

To see the complete compilation of Linux commands, visit this link: List of Linux commands