Linux Essential Commands

Here are some of the essential linux commands for system administrators and all linux users.

Linux Commands

Linux Commands

Below are the top essential linux commands.

Commands to Create Directory & Files in Linux

Create Directory in Linux:

mkdir dirname

Create an empty file on Linux:

touch sample.txt

Create a file on Linux and add some immediate content on it:

cat > sample.txt

How to Delete Files and Directories in the Linux Terminal

To delete a single file:

sudo rm filename

To delete multiple files at once:

sudo rm filename1 filename2 filename3

To remove an empty directory:

sudo rm -d dirname

To remove non-empty directories and all the files within them:

sudo rm -r dirname

To remove multiple directories at once:

rm -r dirname1 dirname2 dirname3

Check File Ownership in Linux

To show who owns a file or what group the file belongs to:

ls -l filename.txt

Change File Ownership Linux

To change the owner and group of a file:

chown USER:GROUP file.txt

Check File Permission in Linux

Check Permissions in Command-Line with Ls Command

ls -l test.txt

It will show you the file permissions and who owns a file or what group the file belongs to.

View file permission in octal notation

stat -c “%a %n” /path/of/file

It will show four things:

File type. There are three possibilities for the type. It can either be a regular file (–), a directory (d) or a link (i).

  • File permission of the user (owner)
  • File permission of the owner’s group
  • File permission of other users

Instead of letters, the octal format represents privileges with numbers:

  • r(ead) has the value of 4
  • w(rite) has the value of 2
  • (e)x(ecute) has the value of 1
  • no permission has the value of 0

The privileges are summed up and depicted by one number. Therefore, the possibilities are:

  • 7 – for read, write, and execute permission
  • 6 – for read and write privileges
  • 5 – for read and execute privileges
  • 4 – for read privileges

Change File Permission in Linux

Using Chmod Command to Change File Permissions

Sudo chmod [permission] [file_name]

Change permission for all directory/folder under the mentioned DirectoryName
sudo find DIRECTORY -type d -exec chmod 775 {} \;

Change permission for all files under the mentioned DirectoryName
sudo find DIRECTORY -type f -exec chmod 664 {} \;

VIM Editor Commands

To search in vim editor:

Open up your file with vim:

sudo vim myfile.txt

Then press ESC to switch to normal mode and type / followed by the word you are searching for.

NANO Editor Commands

Sudo nano filename

Zip and Unzip files in Linux

To zip files in the current directory at first go to the current directory using cd commands.

cd /directory-you-want-to-zip

Now zip all files and contents using

sudo zip -r filename.zip .

To Unzip at first go to the current directory where you want to unzip.

cd /directory-you-want-to-unzip

Now Unzip all the files from a zip.

sudo unzip filename.zip

Commands to Check System Information in Linux

Check OS Version Information:

lsb_release -a

Check Disk Space of Linux Instance:

df -h

Check size of a linux directory:

sudo du -sh /var

Check Processor of Linux machine:

cat /proc/cpuinfo

Check RAM of Linux machine:

cat /proc/meminfo

Disclosure: When you make a purchase using our links, we may earn an affiliate commission.