cat -T | find | xargs -n 3 | uniq | chmod . -R | mkisofs | netstat -tnp | pkill

cat food 1> kitty "equal to>" cat food > kitty
less fex
#!/bin/bash
FILE=$1
if [ -f $FILE ]
then
echo File exists
else
echo Does not exists
fi
------
Remove blank lines
cat fex | tr -s '\n'
Show tabs
cat -T fex
List dirs
find . -type d
multiple criterions
find . \( -name "*file" -o -type d \)
Find all files access last day
find . -atime -1 -type f
Find files less than 2k
find . -size -2k
M – mb
G - Gb
---------
Delete files
find . -name "er*" –delete
Print files with permission 644
find . -perm 644
Cat all files
find . -name "*file" -print  -exec cat {} \;
it’s not possible to use multiple commands with –exec parameter, but we can write multiple commands in shell scripts
-exec ./commands.sh {} \;
xargs
$cat g | xargs
1 2 3 4 5 6 7 9 10 11 12
$ cat g | xargs -n 3
1 2 3
4 5 6
7 9 10
11 12
echo splitXsuplitXsplitXsplit | xargs -d X -n 2
split suplit
split split
------------
Find and delete all files
find . -type f -name "*.txt" -print | xargs rm –f
echo HELLO | tr 'A-z' 'a-z'
hello
echo Hello 123 world | tr -d '0-9'
Hello  world
------------
Verify md5 sum of particular file
md5sum filename > file_sum.md5
md5sum –c file_sum.md5

cat u
hello
hello
hello1
hello2
hello3
uniq -u u
hello1
hello2
hello3
-----------------
By setting the sticky bit, it restricts only the user owning it to delete the files even though group and others have sufficient permissions
How to set sticky bit
chmod +t newdir1/
set permissions 777 recurto all files and directories
chmod 777 . -R
To print the second line:
awk 'FNR == 2 {print}'
To print the second field:
awk '{print $2}'
To print the third field of the fifth line:
awk 'FNR == 5 {print $3}'
Create file with size 10Mbyte
dd if=/dev/zero of=bigfile bs=10M count=1
----------------
mkisofs is a command used to create ISO system
----------------
List opened TCP ports and services
netstat -tnp

ubuntu2@ubuntu2:~$ sudo netstat -p | grep EST
tcp        0      0 ubuntu2.server.loca:ssh 192.168.154.1:50077     ESTABLISHED 7876/sshd: ubuntu2 
tcp        0      0 ubuntu2.server.lo:50237 bud02s24-in-f14.1:https ESTABLISHED 4339/firefox 
----------------
pkill command is similar to the kill command but it accepts a process name instead of a process ID
----------------

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all