Latex
\foreach \n in {0,...,2}{do something \newline}Linux
Delete empty directories
find . -empty -type d -delete
find files and mention the size of each,
find Desktop/prova/ -iname "*.pdf" -exec du -hs {} \;
Find multiple files and remove them
find ~/Desktop/Junk/ -type f -iname "*.zip" -o -iname "*.jpeg" -o -iname "*.srt" -exec rm {} \;
count the files created in the last 1 min
find . -mmin -1 -type f -delete | wc -l
Delete all files created in the last 1 min
find . -mmin -1 -type f -delete
rsync is far better than cp
rsync -zaPv --delete --dry-run abc\ backup\
(dryrun gives the idea about what will be done without doing it
delete will keep the content same on both side
z compression and decompression
P progress
a arkiv
v used in conjunction with dryrun to see the output of what will be done without doing it)
Run periodic command with crontab
crontab -e
list commands to be run and time it has to be run and you are good to go. The following would write hello in helloooo.txt every min 24/7.
* * * * * echo hello >> Desktop/helloooo.txt
select-editor - let you select one
The following might be good to look at to get more info,
https://crontab.guru/
List all software packages on Ubuntu Linux available for us
apt list
Use \textit{grep} to filter out
dpkg --list | grep nginx
Both installed and packages available to install
apt list --installed
How to list or find out if a specific package installed or not
Eg. apt list -a okular
If you wanna search the file, with string, heyboy, in the directory, /home/James/Downloads, do the following (-r and -i stands for search in folder and ignore character case resp.)
grep -r -i "heyboy" /home/James/Downloads
To find abc* in current directory
find . -iname abc*
To find abc* in /Downloads/ directory
find /Downloads/ -iname abc*
Find files (f) in current dir and then feed it to grep({}) to see if it contains text with 'abc', and consequently print it.
find . -type f -exec grep "abc" '{}'\; -print
or
find . -type f -print | xargs grep "abc"
Find and delete the files (BE CAREFUL)
find . -iname "abc" -delete
Join pdf files
pdftk 1.pdf 2.pdf cat output nfile.pdf
To check if some package, say google chrome, is installed,
apt-cache policy google-chrome-stable
To count pdf in given folder,
count *.pdf
count number of lines in a.pdf
wc -l a.pdf
count number of words in a.pdf
wc -w a.pdf
Set up alarm using sleep command
sleep 15m && rhythmbox abc.mp3
'sleep' is used to perform some tasks after the time defined. Example above, I want to play mp3 after 15 minutes.
cron command
https://github.com/CoreyMSchafer/code_snippets/blob/master/Cron-Tasks/snippets.txt
'apt show flowblade' would show me version to be installed and dependencies
sudo apt search paint - would show me all possible software with paint in its description
curl cheat.sh - an awesome thing to get man like description, but very brief, which is what you wished for many times you used man.
In case you wanna close the terminal and some process 36089 is running. So if you close the process might close. If you run the following command, you will not lose the process while closing the terminal
disown 36089
Calibre is one of the best reader, install it
sudo apt install calibre
My favorite commands,
touch
less
man
htop
cat
cat abc - create file abc
cat >abc - prompt to write in abc
cat abc > t - would overwrite t with abc content
cat abc >> t - would append abc to at the end of t content
cat abc | less - shows abc and let you scroll file nicely
nano
Speed up UBUNTU
Change the DNS to Google DNS and speed up your internet,
8.8.8.8, 8.8.4.4 is google DNS. Cloudflare DNS is also a good option, I guess.
Install Ubuntu Restricted Extras (Media Codecs):
sudo apt install ubuntu-restricted-extras
Install Timeshift Backup Tool:
sudo apt install timeshift
Improve Laptop Battery:
sudo apt install tlp tlp-rdw
Firefox Tweaks: Make it work better, doing
1. about:config -- accept
2. layers.acceleration.force-enabled -- set up true value
3. gfx.webrender.all -- set up true value
Every time security updates make you restart the laptop which pisses you off, here is the solution:
Just activate a livepatch and you are good to go.
If you were wondering about how to record the screen on Ubuntu 18.04, here is the answer. To me, Simplescreenrecorder is one of the best software to do so. To do so just run following command in your terminal
sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder && sudo apt update && sudo apt install simplescreenrecorder