Unix/Linux File and Directory Commands



Creating the new file

Display content of the file

Concatenating more than one file

Appending data to the existing file

cp - Copy contents from a file to another file(source to destination)


Renaming a file(changing name of the file)

Renaming a directory

Moves files from one directory to another directory

rm - Delete/remove a file or directory (only if directory is empty).

mkdir - create directories and subdirectories.

mkdir testdir

create multiple directories at one time:

 mkdir testdir1 testdir2 testdir3

create several subdirectories at one time:

 mkdir -p world/countries/states


cd - changing/closing directory

cd ..    : go back to one level

cd /testdir1/testdir2/testdir3 → changing directory

pwd  :  it prints present directory

cd ~     Move to users home directory from anywhere.


rmdir - Remove the directory if it is empty (works only if directory empty)

rmdir world      // error

rm -r world

rmdir testdir1 testdir2 testdir3