0% found this document useful (0 votes)
21 views5 pages

Linux Commands and Sever Management

Uploaded by

kevin jerald
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)
21 views5 pages

Linux Commands and Sever Management

Uploaded by

kevin jerald
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/ 5

SSH : Secure Shell Server Protocol

Commands :
sudo : super user do
Ssh username@ipaddress
* Sudo apt install , update , upgrade
* sudo systemctl status ssh
* sudo apt install openssh-server
* sudo systemctl start ssh
* sudo systemctl enable ssh

ip a : finding ipaddress

pwd : print working directory


ls : list directory
cd ~ : home directory
cd / : root directory
Absolute path ( / ), Relative path

FILE SYSTEM STRUCTURE :

/bin ( user level commands cat , cp , vd ,ls ,etc...)


/sbin ( system/filesystem level commands ( booting , restoring , recovery , repair system
)
/etc ( configuration files of applications and etc...)
/dev ( devices files disk , CDROM ,Flash drive )
/proc ( running process )
/var ( system log files )
/tmp ( directory for temporory files )
/usr ( user programs and commands )
/home ( directory for user )
/boot ( contains files used by boot loader ( grub.cfg) )
/lib ( C-programming files needed by commands and apps )
/opt ( optional add-on apps ( third party appications ) )
/mnt ( to mount removable media manually )
/media ( to mount external hardisk , flashdrive ,CDROM )
/srv ( site specific data FTP , WWW )

lISTING DIRECTORIES :

ls : list directory
ls -f : all files and folders
ls -F : differentiating folders and files
ls -a : hidden files
ls -R : directory and their sub directories
ls -l : detailed information of each directory ( long lasting )
ls -t : sort by modification time
ls -s : sort by file size
ls -h : human readable file
* : all ( wild card character )

touch : to create a file ( eg :touch file_name )


mkdir : make a directory ( eg :mkdir directory_name )
rmdir : remove a directory
cp : coping files ( cp file_name destination_file_name )

LINKS :

Symbolic link - only points towards the file or folder doesnt shows the content inside
the file or folder
both have different inode numbers but linked through symbolic links
Hard link - linking the file directly have same or similar inode numbers and size in
bytes 1032 bytes

echo : writing content inside the file ( eg : echo " content " > file_name
cat : viewing the content inside a file ( eg : cat file_name )
rm : to remove a file (eg : rm file_name )
Symbolic link :
Creating symbolic link :( ln -s directory_name/filename
destination_directory_name/destination_symboliclink_name )
overwriting symbolic link : ln -sf " " ...... .... ... .. .

Hardlink : ln orginalfile_path hardlink_path


viewing : ls -i ( inode ) orginalfile_path hardlink_path
- even if we delete the orginal file the content will not be deleted in the hardlink
file .

Renaming files :
mv : mv file_name,path renamed_file_name,path

Deleting files and directories : rm file_path file_path file_path


rm -i file_path / name
removing a directory : rm -r filename/path

VIEW FILE CONTENT : cat file_path / file_name


more """""" down
less """""" up
head """"""
head -n 2 """" ---
tail """""" ---last no of lines
nl file_path / file_name -- no of lines
vi/vim editor ( exiting --> shift + : q )
file file_name ( finding the type of file )

FINDING FILES : find ~ -name "file_name"


find ~ -name "*.txt"
find ~ -type f,txt,d,etc....
find ~ -mtime -7
locate file
locate "*txt"
which ls,cat,etc..... ( form which the given command is working )
whereis ls,cat,etc.... ( shows along with the helping man file )
find ~ -type f -exec grep -l "file" {} \;

NANO EDITOR : nano file_name


ctrl+o save , enter
ctrl+x exit

VIM EDITOR : i - INSERT MODE


ESC - ESCAPE FOR EXIT editing mode
shift + :
:wq - write and exit

FILE PERMISSIONS : -rw-rw-r-- 1 kevinjerald kevinjerald 98 oct 25 22:34 kevinjerald.txt


- it is a file
d directories
l link
permission for file owner
permission for group members
permission for everyone else
r read
w write
x execute
--- no permission
--x execute only permission
-w- write only permission
-wx- wand execute permission
r-- read only permission
r-x read and execute permission
rw- read and write permissions
rwx read write execute permission
FILE PERMISSION FOR USERS : chmod u - users + add r -- read file_name
g - group - remove w -- write
o - others x -- execute

./file_name.sh ( executable script )

CREATING USERS : sudo useradd user_name


password
sudo passwd user_name
su - switch user
sudo usermod -s /bin/bash user_name ( Changing from shell to BASH
scripting )

CREATING GROUPS : sudo groupadd users


ADDING USER TO GROUP : sudo usermod -aG users kevin
groups kevin

FILE PERMISSIONS FOR OTHERS : sudo chmod o+rx /home/kevinjerald

FILE PERMISSIONS FOR GROUPS : sudo chmod g-rwx file_name

FILE OWNERSHIP (root user) : chown kevinjerald file_name


changing group ownership : chown :kevinjerald file_name

COMPRESS DATA : tar -czvf archiving_file_name.tar.gz folder_name


c - create new archive file
z - archive using gzip
v - verbosely list ( display compressed )
f - file name for the archived file
.tar.gz - extension for archived file saving

EXTRACTING COMPRESSED/ARCHIVED DATA : tar -xzvf archived_file_name.tar.gz -C folder_name


x - extract the contents of the archive
z - decompress using gzip
v - verbosely liost ( display compressed )
f - file/folder name
- C directory to extract files

: zip -r archivefolder_name.zip folder_name


: unzip archivefolder_name -d path

: gzip folder_name_path
: gunzip tonystark.txt.gz

ENVIRONMENT VARIABLES : printenv


env
echo $HOME ( $ symbol must be used while searching for variables
using echo )

LOCAL VARIABLES : Temporary variables and values


echo $MY_VAR
MY_VAR=VALUE ( Assigning value to variable )
unset MY_VAR ( removing value in a variable )

GLOBAL VARIABLES : .bashrc ( our devices golabal variables stored in )


nano .bashrc ( export TEST_VAR="TEST_VALUE" )
source .bashrc ( refresh )
echo $TEST_VAR
printenv

DISK SPACE MANAGEMENT : df , df -h


DISK USAGE MANAGEMENT : du , du -h
PACKAGES : sudo apt install git , remove , purge , autoremove , search , list --installed
,
show .

PROCESS MANAGEMENT : ps , ps aux , top --- q ( exit )

KILLING A PROCESS : ps -u kevinjerald


kill process_id
pkill process_id

TOP 50 COMMANDS :

ls - listing
pwd - print worrking directory
cd - change directory
mkdir - make direcotry
mv - rename and copy the file
cp - copy file
rm - delete the files
touch - create an empty file
ln - creating a symbolic link and hard link
cat - viewing a content of a file
clear - used to clear the terminal
echo - printing any thing in the terminal
less - display only the small content
man - manual pages of linux commands
uname - about operating system
whoami - finding which user is logged in
tar - compress file and decompress file
grep - used to find a single specific word in a text file
head - listing the top 5 or 3 or etc.. based on our requirment
tail - listing the least 5 or 3 or etc.. based on our requirment
diff - finding difference betwwen two files
cmp - compare ( comparing two different files )
comm - do both the work of diff and cmp
sort - can used to sort the file
export - can be used in environment variables for global variables
zip - can used to zip the bunch of files
unzip - can used to unzip the bunch of files
ssh - secure shell login
service - used to start and stop various services in the linux operating system
ps - process information
kill and killall - stop the process
df - disk space
mount - used to find the deviced that are mounted
chmod - file permissions
chown - file ownership
if config and ip a - network information
traceroute - finding how much data and the path sent to a website
wget - used to download files directly
ufw - used to aceess firewall services
iptables - information about network and fire wall
apt packman yum rpm - package management system
sudo - super user do
call - calender
alias - can convert a large command to user readable samll word
dd - bootable drive
whereis - information about linux commands
wahtis - to find for waht the linux command is used
top - to know the information of the running process of applications and etc...
useradd and usermod - adding an user and modifing the details of the user
passwd - can change the passwd of the user

You might also like