Mostly used Linux(Ubuntu) commands for programmers

Linux commands

Here are the mostly used Linux commands that every developer must know:

change directory file permissions in Linux(Ubuntu)…

How to set chmod for a folder and all of its sub folders and files in Linux Ubuntu Terminal?

For this Use following command

chmod -R [permissions] [dirname with path]

Example: chmod – R 777 /home/desktop, Here -R is used to repeat to all sub directories.

Here is the way to set file permissions only for directory in Ubuntu

Use the find Linux command, Example: find /home/desktop/development -type d -exec chmod 755 {} \;

Above command will change all the directory and sub directory permission to 755 under path /home/desktop/development in Ubuntu(Linux)

Here is the way to set file permission only for files in Ubuntu

find /home/desktop/development/ -type f -exec chmod 644 {} \;

Above command will change all files permission to 755 under path /home/desktop/development in Ubuntu(Linux)

All the directory permission should be 755 and files permission should be 644 for websites to correctly operation.

How to create compressed tar file in Linux (Ubuntu)

Here is the command to create compressed tar file in Linux (Ubuntu)

tar -cvzf filename.tar.gz [dirname to compress]

Example: tar -cvzf current-backup.tar.gz /home/desktop/development
Bellow is meaning of each characters used in command

c = Create a new file
v = Display file to compress or uncompress(verbose)
f = Create the file with filename provided as the argument
z = use gzip to zip it
x = extract file

How to Uncompress tar file in Linux (Ubuntu)

Here is the command to Uncompress Tar file in Linux (Ubuntu)

tar -xvzf filename.zip.gz [dirname to compress]

How to Remove directory in Linux (Ubuntu)

rm [dir-path]

Used to remove directory in Linux.

How to Remove directory and sub directory and its files (none empty directory) in Linux (Ubuntu)

and to Remove directory recursively(sub directory and files)

rm -R [dir-path]

-R means recursively.

How to Move directory/files in Linux (Ubuntu)

Use the

mv

command.

How to Copy directory/files in Linux (Ubuntu)

Use the

cp

command.

How to list directory/files in Linux (Ubuntu)

Use the

ls

command.

Leave a Reply