Home - ProfP30/Bash-Foo GitHub Wiki
Location of important config files
- X11:
/etc/X11/xorg.conf
- sudoers:
/etc/sudoers
- fstab:
/etc/fstab
- Terminator:
~/.config/terminator/config
- GRUB2:
/etc/default/grub
- pacman:
/etc/pacman.conf
- micro settings:
~/.config/micro/settings.json
- micro key bindings:
~/.config/micro/bindings.json
- librewolf:
/usr/lib/librewolf/librewolf.cfg
- LightDM:
/etc/lightdm/lightdm.conf
Find all files with extension "png" recursively from here:
find -name '*.png'
Find all files with extension "tmp" recursively from here and deletes it:
find -name '*.tmp' -delete
Count number of lines from an output:
less filename.ext|wc -l
Show all files ordered by size descending:
du -k * | sort -nr | cut -f2 | xargs -d '\n' du -sh | less
Get the top 10 largest files ordered by size descending, starting from the current folder, recursively:
find . -printf '%s %p\n'| sort -nr | head -10
Find 10 largest folders:
du -hsx * | sort -rh | head -10
Show summary info size and name of certain directory:
du -hs dir_name
Show size and name of certain directory and all subdirectories:
du -h dir_name
Extract the first 85 lines from a file:
head -85 file.txt
Extract lines 40-50 from a file, first using head to get the first 50 lines then tail to get the last 10:
head -50 file.txt | tail -10
List the 5 largest subdirectories in the current directory:
du -hs */ | sort | head -n 5
Get the top 10 used commands (read out of the shell-history):
history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5
Search case insensitively for multiple strings in output lines:
pacman -Q|grep -i "zsh\|youtube"
Alternative: Search case insensitively for multiple strings in output lines; "egrip" needs no masking of charachters with backslash:
pacman -Q|egrep -i "zsh|youtube"
Query graphics card:
lspci -nnk | grep -i VGA -A2
Query sound card:
lspci -nnk | grep -i audio -A2
Query general system info:
inxi -Fx
Play the audio track of a YT-Video:
function ytp() { mpv --ytdl-format=bestaudio ytdl://ytsearch:"$*"; }
Extract audio track from a YT-Video and store as mp3:
function yte() { yt-dlp --extract-audio --audio-format mp3 --audio-quality 0 "ytsearch: $1" }
Convert wmv video to mp4 video:
ffmpeg -i inputfile.wmv -c:v libx264 -crf 23 outputfile.mp4
Extract audio stream as mp3 from m4a:
ffmpeg -i input.m4a -c:v copy -c:a libmp3lame -q:a 4 output.mp3
Convert all jpg files from current directory to png:
for i in *.jpg; do convert "${i}" "$(basename ${i}).png"; done
Convert all FLAC-files from current directory to mp3:
for file in *.flac; do ffmpeg -i $file -q:a 0 ${file:r}.mp3; done
Query my external IP address:
curl https://ifconfig.me
Show all installed services:
systemctl list-unit-files --state=enabled --no-pager
Show the services which failed:
systemctl list-units --failed
Show durations of services in a hierarchical tree view for current user:
systemctl status user@1000
Create symbolic link:
ln -s /run/media/Temp/ownCloud/ my_onwcloud/
Change owner:
sudo chown -R root:root ./Ambiant-MATE/
Show boot messages:
sudo dmesg --color=always | less -R
Show messages from last boot:
journalctl -b
Show messages from previous boot:
journalctl -b -1
Add user to sudoers-group:
-
sudoedit /etc/sudoers
-
Scroll down to the end of the file and add the following line:
username ALL=(ALL) NOPASSWD:ALL
How to access a Fritz!NAS:
-
Install following packages:
samba
,cifs-utils
-
In Dolphin: access following address:
smb://[email protected]/FRITZ.NAS
Open a file or URL in the user's preferred application:
xdg-open - opens a file or URL in the user's preferred application!
Manjaro Update mirrors on download errors (404):
sudo pacman-mirrors --fasttrack && sudo pacman -Syyu
Enable OpenGL in LibreWolf config:
-
sudoedit /usr/lib/librewolf/librewolf.cfg
-
"To enable it, comment out the section placed in line 1430 to 1444 of the file."
Check if current session runs on Wayland:
echo $XDG_SESSION_TYPE
Show all installed services:
systemctl list-unit-files --state=enabled --no-pager
Restart network service:
sudo systemctl restart NetworkManager.service
Reboot system:
systemctl reboot
Shutdown system:
systemctl poweroff
Hibernate system:
systemctl hibernate
Check system performance as summary on boot:
systemd-analyze
Check system performance with details on boot:
systemd-analyze blame
Pacman: show all installed packages on the system:
pacman -Q
Pacman: Search package in remote repository:
pacman -Ss packagename
To create a Zip archive of a directory you would use (includes hidden files):
zip -r archivename.zip directory_name
look into zip without extracting:
zip -sf archivename.zip
tar.bz2 extracting:
tar -xjf filename
tar.gz extracting:
tar -xf filename.tar.gz
zip extracting to current folder:
unzip filename.zip
zip extracting to specific folder:
unzip filename.zip -d targetdir
tgz extracting:
tar xzvf filename.tgz
Convert .flac to .mp3 (lossless):
for f in *.flac; do ffmpeg -i "$f" -aq 1 "${f%flac}mp3"; done
Convert .flac to .mp3, compress to ~ 120k:
for f in *.flac; do ffmpeg -i "$f" -aq 5 "${f%flac}mp3"; done
Convert .flac to mp3, compress to ~ 128k:
for f in *.flac; do ffmpeg -i "$f" -b:a 128k "${f%flac}mp3"; done
Convert .flac to mp3, compress to variable 190k:
for f in *.flac; do ffmpeg -i "$f" -aq 2 "${f%flac}mp3"; done
Compress .mp3 files with lame to constant 128k:
for i in *.mp3; do lame --preset 128 "$i" "${i}.mp3"; done
Compress .mp3 to variable 190k (constant quality):
for i in *.mp3; do lame -V2 "$i"; done
Compress .mp3 to variable 190k bitrate and replace files:
for i in *.mp3; do lame -V2 "$i" tmp && mv tmp "$i"; done
Remove all square brackets an the info in between from all filenames in current directory:
(e.g. Carvar & Clock - Tipping Point [Free Download] [ENmR6CCVL2g].mp3
-> Carvar & Clock - Tipping Point .mp3
)
find . -depth -name "*[*" -execdir sh -c 'mv "$0" "$(echo "$0" | sed "s/\[^](/ProfP30/Bash-Foo/wiki/^)*\]//g")"' {} \;