Skip to main content

Basic Linux Commands

 Linux Command Cheat Sheet


Hello All,

Below are the most common commands used in a day to day life of  linux user.

if you are new to linux i will recommend you to go through all of the commands. this commands will help you to troubleshoot linux issues.

 

Command

Description

ls

Lists all files and directories from present working directory

ls-R

Lists files in sub-directories

ls-a

to list down hidden files.

ls-al

Lists files and directories with complete details like permissions, size, owner

cd or cd ~

To go back to home directory

cd ..

Move one level up

cd

To change to a particular directory

cd /

Move to the root directory

cat > filename

Creates a new file

cat filename

Displays the content of a file

cat file1 file2 > file3

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

mv file "new file path"

Moves the files to the new location

mv filename new_file_name

Renames the file to a new filename

sudo

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

rm filename

Deletes a file

man

Gives help information on a command

history

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

clear

Clears the terminal

mkdir directoryname

Creates a new directory in the present working directory or a at the specified path

rmdir

Deletes a directory

mv

Renames a directory

pr -x

Divides the file into x columns

pr -h

Assigns a header to the file

pr -n

Denotes the file with Line Numbers

lp -nc , lpr c

Prints "c" copies of the File

 lp-d lp-P

Specifies name of the printer

apt-get

Command used to install and update packages

mail -s 'subject' -c 'cc-address'   -b 'bcc-address' 'to-address'

Command to send email

mail -s "Subject" to-address < Filename

Command to send email with attachment

 

File Permission commands

 

Command

Description

ls-l

to show file type and access permission

r

read permission

w

write permission

x

execute permission

-=

no permission

Chown user

For changing the ownership of a file/directory

Chown user:group filename

change the user as well as group for a file or directory

Chmod Options Permissions filename

change the permission of a file to read/write/execute

Environment Variables command

Command

Description

echo $VARIABLE

To display value of a variable

env

Displays all environment variables

VARIABLE_NAME= variable_value

Create a new variable

Unset

Remove a variable

export Variable=value

To set value of an environment variable

User management commands of linux

Command

Description

sudo adduser username

To display value of a variable

sudo passwd -l 'username'

Displays all environment variables

sudo userdel -r 'username'

Create a new variable

sudo usermod -a -G GROUPNAME USERNAME

Remove a variable

sudo deluser USER GROUPNAME

To set value of an environment variable

finger

Gives information on all logged in user

finger username

Gives information of a particular user

Networking Commands


Command

Description

SSH username@ip-address or hostname

login into a remote Linux machine using SSH

Ping hostname="" or =""

To ping and Analyzing network and host connections

dir

Display files in the current directory of a remote computer

cd "dirname"

change directory to "dirname" on a remote computer

put file

upload 'file' from local to remote computer

get file

Download 'file' from remote to local computer

quit

Logout

Process command

 

Command

Description

bg

To send a process to the background

fg

To run a stopped process in the foreground

top

Details on all Active Processes

ps

Give the status of processes running for a user

ps PID

Gives the status of a particular process

pidof

Gives the Process ID (PID) of a process

kill PID

Kills a process

nice

Starts a process with a given priority

renice

Changes priority of an already running process

df

Gives free hard disk space on your system

free

Gives free RAM on your system

VI Editing Commands

 

Command

Description

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


Other Topics: Script to Monitor Disk Usage | How to create a Azure VM using Snapshot | Git Commands | Install Kubernetes on Ubuntu

 




Thank you !! Example HTML page Pleaes provide your valuable feedback.

Comments

Popular posts from this blog

Script To Monitor disk Usage

Hello All, Many times we have a requirement to automate few of the tasks, and one of the important task is to delete old log files from log destination. We usually get the conditions where we have to delete the log from particular directory when it reaches to some thresh hold value. Now a day the requirement of automation is highly increased where we are seeing most of the day to day tasks are getting automated using different scripting languages. Its always a good idea to automate your daily tasks which will save your working hours and will increase your productivity. Most of the time log destination gets full and due to which we face other issues like application down or particular service stop working. And manual deleting of log is hectic process so below script will help you to delete your log data when it meets your condition, and also it will trigger mail to recipient after deletion of logs. You can schedule this script in your crontab according to your feasible ti...

Azure Active Directory

  What is Azure Active Directory? Azure Active Directory is Microsoft’s multi-tenant, cloud-based directory and identity management service. For an organization, Azure AD helps employees sign up to multiple services and access them anywhere over the cloud with a single set of login credentials. Azure Active Directory Concept: It is important to understand these Azure AD concepts. Identity . An object that can get authenticated. An identity can be a user with a username and password. Account . An identity that has data associated with it. You can't have an account without an identity. Azure subscription . Used to pay for Azure cloud services. You can have many subscriptions and they're linked to a credit card. Azure tenant/directory . A dedicated and trusted instance of Azure AD, a Tenant is automatically created when your organization signs up for a Microsoft cloud service subscription. More instances of Azure AD can be created. Azure AD is the underlying product ...

Azure Storage

Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios.    Why Azure Storage: Durable and Highly Available: ·        Data is safe during hardware failure. ·        Replicate data across data centres. ·        In local catastrophe or natural disaster data replicated to other data centres remains highly available. Secure: ·        Data encrypted by Azure service Storage Service encryption (SSE) for data at rest. ·        Completed control over who access your data. Scalable: ·        Designed to massive scale. Managed: ·        Azure handles maintenance, updates and critical issues. Accessible: ·        Accessible from anywhere in the world. ·        You can access using http, https,...

Connect SparkThriftServer with Tableau/PowerBI

  Connect SparkThriftServer with Tableau/PowerBI REFERENCE : https://docs.microsoft.com/en-us/azure/hdinsight/hdinsight-apache-spark-use-bi-tools Use Power BI for Spark data visualization Note This section is applicable only for Spark 1.6 on HDInsight 3.4 and Spark 2.0 on HDInsight 3.5.   Once you have saved the data as a table, you can use Power BI to connect to the data and visualize it to create reports, dashboards, etc.   1.       Make sure you have access to Power BI. You can get a free preview subscription of Power BI from http://www.powerbi.com/ . 2.       Sign in to Power BI . 3.       From the bottom of the left pane, click Get Data . 4.       On the Get Data page, under Import or Connect to Data , for Databases , click Get . 5.       On the next screen, click Spark on Azure HDInsight and then click Connect . When prompted, enter th...

Continuous Integration with Jenkins and GitLab

  Enter the credential manager Go into system credentials Add a new credential (private key of slave node where you want to run the job) We need a SSH private key credential. I’m not sure the username matters, but I set it to “git” as that is what the login for gitlab uses. I then pointed it to my *private* key on the machine and gave it a description. Now the key shows up in the system. Once I had setup the ssh private key, which allows Jenkins to connect to the git host over ssh (i.e. git clone git@server:user/repo.git), I needed to setup API Access for Jenkins to get metadata from GitLab. In GitLab go to your user profile. Select “Access Tokens”. Now make a new token, I gave it a descriptive name and made it expire at the end of the decade (I haven’t investigated the pros/cons of expiration date length yet). You are then presented with a screen showing the token. Copy it now, as it won’t be accessible again! You can always create a new one if you mess it up t...