Folder Size
du-and I
File Size
du -h * pattern *
Files older than 'n'days
file-intime +n
Remove files older than 'n'
days
file -mtime + n-exec rm}}
Remove Header and Trailer
sed-i"-e 'Id' -e '$d'
filename
Id → 1st line; $d → last line
Replace in file
sed's/to replace/replace
with/g' filename
Find large files
find <path)-type f-size
+ IG -print
grip excluding directory
grip → R--exclude-dir =
(dir) Cto search?
First word in',' separated file
echo attribute > I cut
- d',' -fl
Print 11th attribute in a 4'
separated file
awk-F "I " ' {print $113'
filename
View files in directory
↳ U
↳ Is-l
↳ Is-ltr
↳ Is-bit
View hidden files
is-a
Create new directory mkdir
< filename?
change permission offile
charmoded? 7, chmod 555
write & search mortally
display contents in a file
cat
difference between grep & awk
grip → search pattern or
string in file
awk → define action based
on pattern and
perform operations
zip files
gzip filenames
unzip files
gunzip-filenames
print 25th line.in file
↳ eat < filenames/head-251
tail-1
↳ cat filenames/sed-n '25 p'
↳ cat < filename > /awk
'N R = = 25'
replacing nth occurrence of a
pattern in a time
sed's/unise/linux 12'
filenames
replacing with occurrence to
all occurrence in a line
Sed's/unise/linux/3g'
filenames
replacing string on a specific
line no
sed '3 slunin/Linux/ ' -
filenames
replacing string on range of
lines
sed '1,3 stunin/Linux/'
- filename?
deleting 5th line
sed 'Sd' filename
deleting line from 3106
Sed '3, Gd' filename
delete pattern matching line
sed-/pattern/d 'filename
specify directory in find
6) : current directory name
(1) : root directory
type in find
type used to specify file type
f: regular file
d: directory
l: symbolic link c:
character devices b:
block devices
find files by name
find.-name "* bit"
find files newer than msg.tret
find.-newer msg. trt
delete file 'Demo. bit' from
current dir
find.-name Demo test
- delete
find location of 'New directory'
find • type-depth-name New
directory
find files modified within last
day
find. /New directory
- mtime -I
find files with 777 permission
find • Kpath) -perm 777
find and replace
find 1 New directory
- type f-exec sed-i 's/find/
replace/g' {3 1;
find tent within multiple files
find. 1 New directory
- type f -name "*. Grit"
- exec grip 'demo' {} 1;
will find line
containing 'demo' withing
Newdirectory
search every directory
find/name filel
- type f -print
options available in find
command
erase all files in the current
directory including all its sub-
directories
rm-r#
grep and egrep
$1s I grip 'enl json.'
will checki for . envlison
literally
$ blegrip '. envl.json' will
check for file with
C. en' or C.json' extension
chmod, chown, chgrp
chmod: it changes the
permission set of a file
chown: it changes the
ownership of the file chgrp:
it changes the group of the
file
mohup
runs a process in the
background even when user
is logged off from the system
Networking commands
• telnet: remote login and
for communication
with another
hostname
• ping: checking network
connectivity
• hostname: gives the IP
address and
domain name
• nslookup: performs a
DNS query
• retraceroute: determine
the number of
hops and
response time
required to reach
the network
host
• metstat: provides info
about system and
port,
routing tables,
interface
statistics, etc.
• tepdump: provides info
about both
incoming and
outgoing network
traffic
ls-F
displays information
about the file type
ls-ltr
display in long format
sorted by modified time
with oldest first.
alias mechanism
alias is used to assign
another name to long,
commands se cg
alias geo = 'get checkout
- b'
Wildcard
It takes place of an
unknown character or set
of characters
* and? are usually
used.
Majorly used in searching
files with unknown
characters in filenames
Mount and Ammount
Mount: mounts a storage
device or file system onto an
existing directory making it
accessible to users
Unmount: detaches the
mounted file.