Simple Linux Commands For Devs - 20 Basic Linux Commands





Linux has more than 600 flavours, every linux flavour has different commands.

Linux is more secure and consume only less space.

Linux is case sensitive, you need to write command as same as you see.it should be dicto

Command to become root user:

sudo - sudo means privilege, you are going to become privileged user

su - su means switch user.

#sudo su - root

In windows we call it as folder, in linux we call it as directory

# ls - to list folders and files

# cd - change directory

# pwd - present working directory or current working directory where you are.

# cd - takes you to the home directory (~)

# touch - touch file1 - it will create an empty file

# cat > file2 - it will ask you what content you want to enter inside.rl + 

# ctrl + D - it will exit from the editor

# vi file3 - it creates a file3 and ask for input what you want to enter inside.

# cp file 2 file 3 - linux does not look whether file is created or not.

# cat file 2 - it will display the content of file 2

# mv file1 file5 - move and cut are same.

# rm file5 - it will remove the file5

# rm -f file5 - it will forecfully remove the file5

# rmdir madblue1 - it will remove the directory only if the folder is empty

# rm -rf - i will remove the directory even if you have files in the directory. rf means recursively abd forcefully

# vi file5 - it creates a file3 and ask for input what you want to enter inside.

# i - it enters the insert mode

# Esc - this exits from the type mode

# :wq - w is for save and q is for quit always remember to push esc when entering : prompt mode)

# :wq! - this does the forecfull and exit from the prompt if you get some errors.

# shift + G - takes you to the last line in vi file

# :20 - it will take you to the 20th line (always remember to push esc when entering : prompt mode)

# :10 - it will take you to the 10th line always remember to push esc when entering : prompt mode)

# :set number - it will show the no of line in the file

# :set nonumber - it will remove numbers

# %s/air/water/g - s means search, change air to water and g means do it for all lines which has air

# dd - to delete the single line ( make sure that you are in esc mode) - it actually does find and replace all

# 3d - delete the 3 lines

# 5d - delete the 5 lines

# 12x - it will remove the first 12 characters

# 10x - it will remove the first 10 characters

# ls -l - it will do long list with permissions

# touch .file1 - it will create a hidden file1

# ls -la - it will list the hidden files

# ls -lrta - it will list in the order

# a - it will show hidden files 

# - - it means it is a file

# d - it means a directory

# chmod - to change permission


----    ----     -----

root   group  others    

read = 4

write = 2

exe = 1  = 7

- rw- r-- r--

  6   4   4

# chmod 644 

# if the color is changed on file, then the file is executable

# free -m - displays the ram usage in mb

# free -k - displays the ram usage in kb

# free -G - displays the ram usage in gb

# sar - shows the utilization of the CPU every 10 mins.

# top - shows the processor load information

# ps -ef - it shows all the running process

# ps -ef | grep ubuntu - it shows the only filtered running process

# grep - it means asking to do a search

# Top - it shows only the running process ( ctrl +c will exit )

# df -h - it will show the entire disk information

# du -sh madblue1 - it will show the disk utilization 

# du -sh * - it will show all the disk utiliztion of the files and folders in listing manner

# gzip file1 - it will compress the file1 and it will be as file1.gz

# gunzip file1 - it will unzip the file1

Most used flavour in india

ubuntu

redhat

centos


Post a Comment

0 Comments