0% found this document useful (0 votes)
9 views7 pages

Day 1-4 Commands

The document provides a comprehensive list of Linux commands categorized into system commands, hardware commands, and file commands, along with their descriptions. It also includes information about the VIM editor, detailing its modes and commands for editing files. Additionally, it explains file types, permissions, and access control lists (ACL) in Linux.

Uploaded by

Rakesh Mirchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

Day 1-4 Commands

The document provides a comprehensive list of Linux commands categorized into system commands, hardware commands, and file commands, along with their descriptions. It also includes information about the VIM editor, detailing its modes and commands for editing files. Additionally, it explains file types, permissions, and access control lists (ACL) in Linux.

Uploaded by

Rakesh Mirchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

COMMANDS DESCRIPTION

SYSTEM COMMANDS
uname used to get OS
uname -r Displays Linux kerner version
uname -a Displays all information about Linux system information
uptime Displays since how system has been running
uptime -p Shows uptime in pretty format
uptime -s Shows uptime in pretty format
hostname Displays the Hostname
hostname -i Displays IP addresses for the host name
hostname -I Displays IP addresses for the host name
last reboot Shows system reboot history
ip addr Shows addresses assigned to all network interfaces
ip route Show table routes
ifconfig Displays the IP address of the system
date Shows system date and timestamp
date +”%d” Prints day of the month (01-31)
date +”%m” Prints the month of the year 01-12
date +”%y” Prints only the last two digits of Year
date +”%H” Prints the hour 00-23
date +”%M” Prints the Minute of the hour 00-59
date +”%S” Prints the current seconds count in the minute (00-60)
date +"%D" Prints Date in MM/DD/YY
date +”%F” Prints only the Full date as YYYY-MM-DD
date +”%A” Prints the Day of the Week Saturday-Sunday
date +”%B” Prints the month between January-December
who Prints information about default user in our server
whoami Prints information about all users who are currently logged in
HARDWARE COMMANDS
lscpu Displays information about the CPU architecture
lsblk -a Lists the information about all the block devices attached to the system
free Displays system memory(RAM) details in KB
free -m Displays system memory(RAM) details in MB
df Report file system disk space usage
df -h Report file system disk space usage in human readable languages
cat /proc/cpuinfo Displays information about the CPU architecture
cat /proc/meminfo Displays system memory(RAM) details
fdisk -l List the partition tables for the specified devices

FILE COMMANDS
touch file-name used to crete a single file
touch f1 f2 f3 used to create multiple files
touch file{1..5} create 5 files at a time
rm file used to remove single file
rm f1 f2 f3 used to remove multiple files
rm file{1..5} used to remove 5 files
rm -f filename used to remove a file without our permission
rm -f * used to remove all files at a time
mkdir folder1 used to create a single folder
mkdir f1 f2 f3 used to create multiple folders
mkdir folder{1..7} used to create 7 folders
rmdir folder-name used to remove a folder
rmdir f1 f2 f3 used to remove multiple folders
rmdir * used to remove all folders at a time
rmdir folder{1..5} used to remove 5 folders
FILE COMMANDS
touch file-name used to crete a single file
touch f1 f2 f3 used to create multiple files
touch file{1..5} create 5 files at a time
rm file used to remove single file
rm f1 f2 f3 used to remove multiple files
rm file{1..5} used to remove 5 files
rm -f filename used to remove a file without our permission
rm -f * used to remove all files at a time
mkdir folder1 used to create a single folder
mkdir f1 f2 f3 used to create multiple folders
mkdir folder{1..7} used to create 7 folders
touch foldername/filename used to create a file inside the folder
mkdir foldername/foldername used to create a folder inside a folder
mkdir -p foldername/foldername/foldername used to create folders inside a folder
cd foldername used to change the directory
cd .. used to back to one step back
cd - used to go back to the previous directory
cd used to go to root directory at a time
pwd present working directory
rmdir folder used to remove empty directory
rmdir * used to remove all empty directories
rm -rf * used to remove all files and folders at a time
ll used to see all the files along with the data
ls used to see only file names
ls folder1 used to see the list of files present in folder1
ll -a used to see hidden files
ll -r used to see the files in reverse order
ll -t used to see the latest files in top
ll -ltr To list the files in long listing format with sort by modification time, newest first and then in reverse order
cat>filename used to overwrite the data in a file
cat>>filename used to append the data into a file
cat filename used to read the data into a file
cat -n filename used to read the data along the line numbers
tac filename Displays the file1 content in reverse ie last line first
rev filename used to reverse the content in a file
cat f1 f2 f3 used to see all the files data at a time
more f1 f2 f3 used to see all the files data at a time with percentages
head filename used to print first 10 lines of a file
tail filename used to print last 10 lines of a file
sed -n '5,9p' filename used to print the lines between 5 to 9
sed -n '7p' filename used to print the 7th line
head -n 8 filename prints 8 lines in a file
tail -n 4 filename used to print last 4 lines in a file
wc filename used to get the no of lines, words, letters in a file
wc -l filename used to get only line numbers of a file
wc -w filename used to get no of words in a file
wc -c filename used to get no of characters in a file
cp file1 file2 used to copy the data from file1 file2
cat file1 >> file2 used to append the data from file1 file2
cp file1 folder1 used to copy file1 to folder1
mv file1 file2 used to move the data from file1 to file2
mv file1 folder1 used to move file1 to folder1
echo folder{2..7} | xargs -n 1 cp -v folder1/* copy files from folder1 to folder2 to folder7 at a time
cmp file1 file2 used to compare the 2 files
diff file1 file2 used to get the differences of a file b/w 2 files
VIM EDITOR - LINUX - DAY-03

VIM EDITOR: IT IS A EDITOR IN LINUX OS WHICH IS USED TO EDIT THE REGULAR FILES.

WE HAVE 3 MODES IN VIM EDITOR

1. COMMAND MODE
2. INSERT MODE
3. SAVE & QUIT MODE

1. COMMAND MODE: IT IS USED TO PERFORM SOME ACTIONS LIKE COPYING THE DATA,
DELETE THE DATA, UNDO THE DATA ETC..

COMMAND IS THE DEFAULT MODE IN VIM EDITOR

gg : used to go to first line of the file

G : used to go to last line of the file

3gg : used to go to 3rd line of a file

:3 : we can go to 3rd line of a file

: set number : used to set numbers to a file

yy : used to copy the line

3yy : used to copy 3 lines

p : used to paste the data

3p: it prints the copied content 3 times

dd : delete the line

5dd : delete 5 lines at a time

u : used to undo the changes

ctrl + r : used to redo the changes

/word : used to search for a word

?word : used to search for a word


INSERT MODE: IT IS USED TO INSERT THE DATA INTO A FILE. IN INSERT MODE, KEYS WILL
NOT GETS WORK.

i : used to go to insert mode

esc : used to go to command mode from insert mode

A : used to go to the end of the line

I : used to go the starting of the line

O : used to create a new line (up)

o : used to create a new line (down)

SAVE & QUIT : IT IS USED TO SAVE THE DATA IN A FILE AND QUIT FROM VIM EDITOR

:w : to save the data

:w! : forcefully save the data

:q : used to quit from vim editor

:q! : forcefully quit from vim editor

:wq : save& quit will happen at a time

:wq! : save & quit forcefully

============================================

TO UNDERSTAND ABOUT THE FILE/FOLDER

-rw-r--r-- 1 root root 553 Apr 5 02:21 aws

type of the file:

hyphen (-) : regular file

d : directory file (folder)

c : character file

b : blocked file

PERMISSIONS: rw-r--r--
r : read : 4

w : write : 2

x : execute : 1

hyphen (-) : nothing : 0

ACL (Access Control List) :

file ---> 1

folder ---> 2

OWNERS:

user : root

group : root

NO OF CHARACTERS IN A FILE:

553

FILE CREATION DETAILS : Apr 5 02:21

FILE NAME: aws

You might also like