Linux basic Commands


#Lists all files and directories in the present working directory
$ ls

#Lists files in sub-directories as well
$ ls -R

#Lists hidden files as well
$ ls -a

#Lists files and directories with detailed information like permissions,size, owner, etc.
$ ls -al

#Navigate to HOME directory
$ cd 
$ cd ~

#Move one level up
$ cd ..

#To change to a particular directory
$ cd

#Move to the root directory
$ cd /

#Creates a new file
$ cat > filename

#Displays the file content
$ cat filename

#Joins two files (file1, file2) and stores the output in a new file (file3)
$ cat file1 file2 > file3

#Moves the files to the new location
$ mv file "new file path"

#Renames the file to a new filename
$ mv filename new_file_name

#Allows regular users to run programs with the security privileges of the superuser or root
$ sudo

#Deletes a file
$ rm filename

#Gives help information on a command
$ man

#Gives a list of all past commands typed in the current terminal session
$ history

#Clears the terminal
$ clear

#Creates a new directory in the present working directory or a at the specified path
$ mkdir directoryname

#Deletes a directory
$ rmdir

#Renames a directory
$ mv

#Divides the file into x columns
$ pr -x

#Assigns a header to the file
pr -h

#Denotes the file with Line Numbers
$ pr -n

#Prints “c” copies of the File
$ lp -nc , lpr c

#Specifies name of the printer
$ lp-d lp-P

#Command used to install and update packages
$ apt-get

#Command to send email
$ mail -s 'subject' -c  'cc - address' -b ' bcc - address' 'to - address'

#Command to send email with attachment
$ mail -s "Subject" to - address < Filename

File Permission Commands


#To show file type and access permission
$ ls -l

r - Read permission
w - Write Permission
x - execute permission

#Giving permission to any file
$chmod 755 file_name

#Changing ownership of user and group for any file
$ chown user:group filename

Environment Variables Command


#To display  value of a variable
$ echo $VARIABLE 

#Displays all environment variables
$ env

#Create a new variable
$ VARIABLE_NAME= variable_value

#Remove a variable
$ Unset

#To set value of an environment variable
$ export Variable=value

User management Commands of linux


#To add a new user
$ sudo adduser username

#To change the password of a user
$ sudo passwd -l 'username'

#To remove a newly created user
$ sudo userdel -r 'username'

#To add a user to a group
$ sudo usermod -a -G GROUPNAME USERNAME

#To remove a user from a group
$ sudo deluser USER GROUPNAME

#Shows information of all the users logged in
$ finger

#Give information of a particular user
$ finger username

Networking Command


#Login into a remote Linux machine using SSH
$SSH username@ip - address or hostname

#To ping and Analyzing network and host connections
$ Ping hostname="" or =""

#Display files in the current directory of a remote computer
$ dir

#Change directory to "dirname" on a remote computer
$ cd "dirname"

#Upload 'file' from local to remote computer
$ put file

# Download 'file' from remote to local computer
$ get file

#Logout
$ quit

Process Command

bg - To send a process to the background 
fg - To run a stopped process in the foreground
topDetails on all Active Processes
psGive the status of processes running for a user

# Gives the status of a particular process
$ ps PID

#Give the process ID (PID) of a process
$ pidof

#Kills a process
$ kill PID

#Starts a process with a given priority
$ nice

#Changes priority of an already running process
$ renice

#Gives free hard disk space on your system
$ df

#Gives free RAM on your system
$ free

VI Editing Commands

i - Insert at cursor (goes into insert mode)
a - Write after cursor (goes into insert mode)
A - Write at the end of line (goes into insert mode)
ESC - Terminate insert mode
u - Undo last change
U - Undo all changes to the entire line
o - Open a new line (goes into insert mode)
dd - Delete line
3dd - Delete 3 lines
D - Delete contents of line after the cursor
C - Delete contents of a line after the cursor and insert new text. Press ESC key to end insertion
dw - Delete word
4dw - Delete 4 words
cw - Change word
x - Delete character at the cursor
r - Replace character
R - Overwrite characters from cursor onward
s - Substitute one character under cursor continue to insert
S - Substitute entire line and begin to insert at the beginning of the line
~ - Change case of individual character






DevOpsMap

Learn today for better tomorrow

0 Comments