Friday, April 25, 2025

Linux Basic Commands

Class 12th S3 Linux Apr25th

Linux is kernel not operating system it will interact with user interface and system hardware components using Linux kernel amazon created amazon linux it is not Gui, Linux more secure less space occupied
compared to windows, window required 30 GB create VM but linux 8 GB is sufficient fast to access 
Linux flavor(Ubuntu , Redhat,SUSE Linux,Debian) these are available in AWS 
Amazon linux Ec2-user is administator user just Iam user super user is root 
Linux Directory Architecture
/ Root Directory

/bin  /bin stand for binary,and  its where essential command-line  programs(binaries) are stored 

/boot Boot loaded files (like the linux kernel)

/dev Device files (e.g.. /dev/sda, dev/null)

/etc system-wide configuration files

/home home directory for users (eg.. /home/ec2-user)

/lib  Essential shared library for binaries in /bin these shared libraries are dynamic libraries that provide code and data to programs at runtime 

/media mount point for removable media like USB

/mnt Temporary mount point for filesystems(can be used for manual mounts like EFS or s3)

/opt Operational or third-party software packages 

/root Home directory of the root user 

/srv data for services like FTP or webservers 

/tmp temproray files (cleared or reboot)

/proc virtual file system with process and kernel information 

/var variable data like logs(/var/log),mail,spool files 

System Commands

uname (Used for operation system information)

uname -r Display linux kernel version 

uname -a Displays all information about linux system information 

uptime Displays since how long the system has been running 

uptime -p Show uptime when system was up

uptime -s Show uptime different format

hostname Displays the hostname (private ip willshow)

hostname -i /hostname -I Displays the hostname with ip address

last reboot  Give the information last reboot

date Shows date and time 

date +"%d"  day of the month (01-31)

date +"%m%" month of the year (01-12)

date "+%y" last two digits of the year 

date "+%H" print hours (00-23)

date "+%M" print minutes(00-59)

date "+%S" print current seconds(00-60)

date "+%D" print current date(dd/mm/yy)

date "+%F" print full date(YYYY-MM-DD)

date "+%A" print day of the week 

date "+%B" print month of the year

timedatectl shows shich time zone (sudo timedatectl set-timezone Asia/Kolkata)

whoami current which user your

who current how many user connected 

curl ifconfig.me  it give public ip (c stand client url)

File Commands

touch file-name used to create a single file 

touch  f1 f2 f3 multiple file to create

touch file{1.10} create 10 files at time 

rm file   remove single file 

rm f1 f2 f3 remove multiple files 

rm file{1..5} used remove range of 5 file

rm -f Used remove forcefully 

rm -f * remove all files at time

Folder Level Operation 

mkdir FN used to create directory 

mkdir FN1 FN2 FN3 Used to create muliple directory 

mkdir FN{1..7} Used to create range of directories

touch FN/FN used to create file creating inside the folder 

mkdir -p FN/FN/FN used to create folders inside the folder

rmdir used remove empty directory only 

rmdir  * used to remove all empty directories 

rmdir -rf it will remove all file and including content folders

List files 

ll To see the files along the data

ls to only the file names

ls <<foldename>> list of file inside the folder 

ll -a  To see hiden files 

ll -r To see the files reverse order 

ll -t  To see the latest file top 

ll -ltr To list of file along listing format modified time ,newest first and then reverse order 

Edit and display in files 

vim <filename> To Write the data of the file 

cat  <filename>   To read the data of the file

tac <filename>  To display file data in reverse order 

rev <filename>  To reverse the content in the file

Save & Quit 

:w to save the file changes 

:wq save & quit 

:q quit the vim editor

:w! To Save changed forcefully

:q1 quit the file forcefully

:wq! save & quit forcefully

A Move the cursor to end of the file 

I Move the cursor to starting of the file 

O Create new line in the above of the cursor 

o Create new line in the below of the cursor 


Need to Git account, Git is centralized repository store the data ,it will help work multiple people same time ,usually company projects are private repositories 

                             --Thanks ---
















No comments:

Post a Comment