This is a simple guide for non-pro bash users to do random but annoying tasks in just seconds
Your boss will be happy and you'll be less stressed ;)
find | grep "<string>"
grep -R "<string>" <path>
It will show all the files that have that string inside it.
To count the number of coincidences:
find . -type f -exec grep -i "1424421066776" {} + | wc -l
for i in *.pdf; do echo $i; pdftotext "$i" - |grep -i -n 'frase'; done
Source (Spanish): [http://www.ubuntizando.com/busca-texto-en-multiples-pdf-a-la-vez/]
Example
pdfimages -f 15 -l 181 input.pdf base_output_name
Where -f is the beginning page, and -l is the finish page
If you want to extract all the images from various pdf files inside a folder you can use:
for i in *.pdf; do echo $i; pdfimages -j -p "$i" base_image_output_name; done
Where ** -j** means jpg images and -p means include page numbers in output file names
Example:
pdfunite file_1.pdf file_2.pdf file_n.pdf fusion_output.pdf
Another useful way to do this, is putting all the pdf files that you want to fusion in one folder and write:
pdfunite *.pdf fusion_output.pdf
Example:
pdfseparate -f 3 -l 34 input_file.pdf output_file_%d.pdf
Where -f is the beginning page, and -l is the finish page and %d means the number of page
Source (Spanish): [https://www.atareao.es/ubuntu/trabajando-con-pdf-desde-el-terminal-en-ubuntu/]
Example:
exiftool -Title="This is the Title" -Author="Happy Man" -Subject="PDF Metadata" file.pdf
You will need to install the libimage-exiftool-perl package
Source: [https://askubuntu.com/questions/27381/how-to-edit-pdf-metadata-from-command-line#39906]
Use the command ls hw
sudo ls hw
The prompt will give you all the details of your CPU, USB etc.
Using the Google advanced search:
site:thingiverse.com OR site:yeggi.com OR site:cgtrader.com OR youmagine.com OR grabcad.com OR stlfinder.com DINOSAUR
Source (English): [https://blog.astroprint.com/the-ultimate-3d-printing-cheat-sheet/]
Using youtube-dl:
youtube-dl http://youtube.com/thevideourl
youtube-dl has a lot of options that you can find writing "youtube-dl --help":
- -c Continues with a failed download
- -i ignore fails and continues with the next video
There's a lot of options but the most common and easier is:
youtube-dl --all-subs http://youtube.com/thevideourl
You must convert this url to this:
http://http://www.youtube.com/watch?v=V7RHrn2jvgg&playlist?list=PLB5DD0DDCDE1C3C47
http://http://www.youtube.com/playlist?list=PLB5DD0DDCDE1C3C47
Use the following command:
youtube-dl -ci --all-subs http://youtube.com/playlisturl
Where -c means download the failed videos, -i means ignore the errors and keep going and --all-subs will download all the available subtitles
Source (Spanish): [http://www.tuxylinux.com/descargar-playlist-de-youtube-con-youtube-dl/]
First of all you have to create a .txt file where each line is one of the youtube videos url
Use the following command:
youtube-dl -a links.txt
Where "links.txt" is the name of the file. Remember that you can combine this option -a with others parameters as -c, -i, etc.
Source (Spanish): [https://blog.desdelinux.net/youtube-dl-tips-que-no-sabias/]
Use the option --extrac-audio and --audio-format
Use the following command:
youtube-dl --extract-audio --audio-format mp3 link
Where --extract-audio download the video and extract the audio and --audio-format convert the audio to the desired format (mp3, ogg, etc.). To extract audio you'll need the last version of youtube-dl: [https://yt-dl.org/update]
Source (Spanish): [https://gilberto286.wordpress.com/2013/06/05/como-extraer-el-audio-de-un-video-de-youtube-utilizando-youtube-dl-en-ubuntu/]
You can send an email from the terminal using the command mail
mail -s "Test Subject" [email protected] < /dev/null
Where -s is the option for writting a subject.
If you want toi send an email with a body you can write:
mail -s "Test Subject" [email protected]
After that, writte your email and press ctr+d to finish and send the email
Source (Spanish): [https://victorhckinthefreeworld.com/2014/04/23/enviar-correo-desde-la-linea-de-comandos-con-mail/]
You can try:
sudo nmap -sP 192.168.1.1-254
Keep in mind that the main IP(192.168.1.1 to 192.168.1.254) could change in your network.
Source (Spanish): [https://nideaderedes.urlansoft.com/2013/12/23/linux-como-puedo-saber-que-maquinas-hay-conectadas-en-mi-red-local/]
Just write:
python -m SimpleHTTPServer
A simple webserver will be created with the contents of the actual folder. Go to http://localhost:8000 in your browser to see it. Source (Spanish): [http://mundogeek.net/archivos/2016/11/07/los-10-comandos-mas-utiles-de-linux/]
wget -r -np -l 1 -A zip http://example.com/download/
Where -l 1 defines the number of subpages to look, and -A the formats to download.
mkdir -p /path-main-folder/folder{1..4}
It will create the main-folder or the existing path, and inside it, the folders named as "folder1, folder2, etc"
Source: [https://zillowtech.com/install-yarn-on-ubuntu.html]
Use csplit:
csplit filename.mp4 4 -f filename_part
Where 4 is the number of parts and -f with the following name (filename_part) determines the base name
cat filename_part0[0-3] > filename.mp4
Source (Spanish): [https://www.linuxadictos.com/csplit-coge-hacha-parte-los-ficheros-grandes-partes.html]
The most quickly way to see the difference between two files is using the command diff:
diff filename1.txt filename2.txt
The pront will show the differences founded in each line.
mkdir ./base_folder_name{1..N}
Where N is the last folder number
Source (Spanish): [https://www.enmimaquinafunciona.com/pregunta/71792/bucles-en-bash-para-crear-carpetas-numeradas-secuencialmente]
Sometimes the trash folder doesn't work properly. You can delete the files using the command:
sudo rm -rf ~/.local/share/Trash/*
REMEMBER THAT ONCE YOU DELETED THE FILES YOU CANNOT RECOVER THEM
Use pkill
pkill nautilus
Use xkill
xkill
The most easy way to do this is using the sleep command:
sleep 5 m
In this case, we're waiting 5 minutes
Where 5 is the amount of time, m the unit (minutes=m, seconds=s, hours=h)
To execute a command after this time just use &&
sleep 5 m && echo "Time finished"
dpkg -i package.deb
Where -i means install.
Source (Spanish): [https://hipertextual.com/archivo/2014/02/instalar-paquetes-deb-con-dpkg/]
dpkg --get-selections
To filter the list just use grep
dpkg --get-selections | grep keyword
dpkg -r package.deb
Where -r means remove.
Source (Spanish): [https://hipertextual.com/archivo/2014/02/instalar-paquetes-deb-con-dpkg/]
dpkg -p package.deb
Where -p means remove.
Source (Spanish): [https://hipertextual.com/archivo/2014/02/instalar-paquetes-deb-con-dpkg/]
sudo dpkg --remove --force-remove-reinstreq package_name
Source (Spanish): [http://www.ubuntu-es.org/node/25860]
Inside Duck and go just search:
<yourlanguageorthing> cheatsheet
You'll see a cheatsheet with all the commands that you need.
Example:
markdown cheatsheet
In your browser just write one of this URLs:
Documents: doc.new, docs.new, documents.new
Cheatsheets: sheet.new, sheets.new, spreadsheet.new
Presentations: slide.new, slides.new, deck.net, presentation.new
Websites: site.new, sites.new, website.new
Forms: form.new, forms.new
Source (Spanish): [https://www.genbeta.com/truco/como-crear-forma-instantanea-cualquier-tipo-documento-google-docs]
Put your command and the following notify-send command
make && notify-send "Task complete."
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n LENGTH | tr -d '\n'; echo
Where you have to put in length the desired number. Example with a passworf of 8 characters:
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 8 | tr -d '\n'; echo
Source (Spanish): [https://blog.desdelinux.net/aprendiendo-shell-scripting-grep/]
ffmpeg -i input.mp4 -pix_fmt rgb24 output.gif
Where -pix_fmts it's an optional argument that shows the available pixel formats
Source: [https://askubuntu.com/questions/770165/how-to-convert-edit-mp4-file-to-gif-in-ubuntu-16-04]