Remove all empty sub-dirs
find . -type d -empty -print
find . -type d -empty -delete
Mass re-name of directories
for FILE in * ; do NEWFILE="D$FILE"; mv "$FILE" $NEWFILE ; done
find pattern: grep -rnw '/path/to/somewhere/' -e 'pattern'
Find latest 50 modified files recursively
find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n 50
sudo into user
sudo -u user2 zsh
sudo -i -u jira
Opened files: http://www.cyberciti.biz/tips/linux-procfs-file-descriptors.html
Screens: https://admins.su/kak-polzovatsya-utilitoj-screen-v-linux/
Check pop3 by ssl:
openssl s_client -crlf -connect outlook.office365.com:995
USER username
PASS password
-ERR Logon failure: unknown user name or bad password.
Remove all special characters:
Cut part of file
tail -143046 catalina.out.2019-03-11 > catalina.out.2019-03-11_3
RSYNC -
rsync -cavzhrP --dry-run --delete root@192.168.0.100:/home/tarunika/rpmpkgs /tmp/myrpms
Directories size
du -sh * | sort -h
Change in all files
find . -type f -name "*groovy" -exec sed -i 's/jira.sss/jirastage.sss/g' {} +
Tar with maximum effect:
XZ_OPT=-9 tar -Jcvf file.tar.xz /path/to/directory
tat xf for untar it
$ gzip -9 -c file.txt > file.txt.gz
Check secure Pop
openssl s_client -crlf -connect outlook.office365.com:995
+OK The Microsoft Exchange POP3 service is ready.
USER username
+OK
PASS xxxxxxxx
+OK User successfully logged on.
Count lines in all groovy files recursively:
wc -l **/*.groovy
Count files recursively
find . -type f | wc -l
Open ports:
netstat -tulnp
Set time immediately
rdate -s tick.greyware.com
$ echo "Australia/Adelaide" | sudo tee /etc/timezone Australia/Adelaide $ sudo dpkg-reconfigure --frontend noninteractive tzdata Current default time zone: 'Australia/Adelaide' Local time is now: Sat May 8 21:19:24 CST 2010. Universal Time is now: Sat May 8 11:49:24 UTC 2010.
/etc/cron.daily/ntpdate containing:
#!/bin/sh ntpdate ntp.ubuntu.com
sudo apt-get install ntp