Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
linux:start [2020/01/06 22:04] – [Useful shell] mh | linux:start [2022/05/30 22:29] – [Useful shell] mh | ||
---|---|---|---|
Line 14: | Line 14: | ||
#print user PATH | #print user PATH | ||
$ printenv PATH | $ printenv PATH | ||
+ | / | ||
+ | $ echo " | ||
/ | / | ||
Line 23: | Line 25: | ||
| | ||
| | ||
+ | |||
+ | #Add a folder to path for current shell session | ||
+ | $ PATH=$PATH:/ | ||
</ | </ | ||
Line 75: | Line 80: | ||
The menu entry will appear after logging out. | The menu entry will appear after logging out. | ||
+ | === Locate a binary === | ||
+ | |||
+ | <code bash> | ||
+ | $ type man | ||
+ | man is / | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | ===== AppImages ===== | ||
+ | |||
+ | Extract the content of an AppImage : | ||
+ | |||
+ | ./ | ||
+ | |||
+ | This is useful if you want to get the Icon. | ||
+ | |||
+ | [[https:// | ||
+ | ---- | ||
+ | |||
+ | ===== Grub ===== | ||
+ | |||
+ | Config file is located at ''/ | ||
+ | |||
+ | The line for a splash image is '' | ||
+ | |||
+ | ---- | ||
===== Limit CPU usage ===== | ===== Limit CPU usage ===== | ||
- | There are various ways to limit the CPU usage of a process. One simple way is using ' | + | There are various ways to limit the CPU usage of a process. One simple way is using '' |
- | < | + | < |
- | cpulimit -P / | + | $ cpulimit -P / |
</ | </ | ||
[[https:// | [[https:// | ||
+ | ---- | ||
===== Fonts install (bash) ===== | ===== Fonts install (bash) ===== | ||
To quickly install folders containing many OpenType fonts (OTF) or TrueType fonts (TTF), copy to the following locations : | To quickly install folders containing many OpenType fonts (OTF) or TrueType fonts (TTF), copy to the following locations : | ||
- | < | + | < |
- | sudo cp -r / | + | $ sudo cp -r / |
- | sudo cp -r / | + | $ sudo cp -r / |
</ | </ | ||
Regenerate font cache : | Regenerate font cache : | ||
- | < | + | < |
- | sudo fc-cache -f -v | + | $ sudo fc-cache -f -v |
</ | </ | ||
Line 109: | Line 140: | ||
===== Manipulate pdf ===== | ===== Manipulate pdf ===== | ||
+ | |||
+ | ==== Modifying page order ==== | ||
Use (< | Use (< | ||
//For example to extract two pages out of a pdf// | //For example to extract two pages out of a pdf// | ||
- | <code> | + | < |
- | < | + | |
$ pdf-stapler cat in.pdf 2-3 out.pdf | $ pdf-stapler cat in.pdf 2-3 out.pdf | ||
</ | </ | ||
+ | Old syntax with pdftk : < | ||
- | === Ubuntu === | + | === Ubuntu |
pdfshuffler is a front end for python-pyPdf and a great tool for merging or splitting pdf files with a GUI. | pdfshuffler is a front end for python-pyPdf and a great tool for merging or splitting pdf files with a GUI. | ||
+ | |||
+ | ==== Reducing PDF size ==== | ||
+ | |||
+ | Found from [[https:// | ||
+ | this answer]] on AskUbuntu : | ||
+ | |||
+ | <code bash> | ||
+ | gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | *''/ | ||
+ | *''/ | ||
+ | *''/ | ||
+ | *''/ | ||
+ | *''/ | ||
+ | |||
Line 131: | Line 182: | ||
Run **dmesg** to check. If you see lines such as : | Run **dmesg** to check. If you see lines such as : | ||
- | < | + | < |
[54259.098330] FAT-fs (sdb1): error, corrupted directory (invalid entries) | [54259.098330] FAT-fs (sdb1): error, corrupted directory (invalid entries) | ||
[54259.098338] FAT-fs (sdb1): Filesystem has been set read-only | [54259.098338] FAT-fs (sdb1): Filesystem has been set read-only | ||
Line 142: | Line 193: | ||
Run the following command : | Run the following command : | ||
- | < | + | < |
- | sudo umount /dev/sdX# | + | $ sudo umount /dev/sdX# |
- | sudo fsck.msdos -aw /dev/sdX# | + | $ sudo fsck.msdos -aw /dev/sdX# |
</ | </ | ||
Line 175: | Line 226: | ||
If a NTFS volume mounts in read-only, remount using : | If a NTFS volume mounts in read-only, remount using : | ||
- | < | + | < |
- | su | + | $ su |
- | mkdir /mnt/ntfs | + | $ mkdir /mnt/ntfs |
- | mount -t ntfs /dev/sd[X] /mnt/ntfs | + | $ mount -t ntfs /dev/sd[X] /mnt/ntfs |
</ | </ | ||
Line 271: | Line 322: | ||
//Note to self : Added " | //Note to self : Added " | ||
+ | ==== Fixing python on youtube-dl ==== | ||
+ | |||
+ | If following error occurs while using '' | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | === If python3 is not installed === | ||
+ | |||
+ | <code bash> | ||
+ | $sudo apt install python3 | ||
+ | </ | ||
+ | |||
+ | |||
+ | === If python3 is installed === | ||
+ | |||
+ | <code bash> | ||
+ | $whereis python3 | ||
+ | $sudo ln -s / | ||
+ | </ | ||
+ | |||
+ | Change first argument according to where python3 is installed. | ||
===== Linux Screencast tools ===== | ===== Linux Screencast tools ===== | ||
Line 279: | Line 353: | ||
*add-apt-repository ppa: | *add-apt-repository ppa: | ||
+ | ===== Open VPN ===== | ||
+ | |||
+ | === Connecting a client to a remote server === | ||
+ | //This requires a valid .ovpn file// | ||
+ | |||
+ | |||
+ | < | ||
+ | openvpn --config / | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | === Connecting to shared folders through openvpn === | ||
+ | //This requires the ip of the shared folders location// | ||
+ | |||
+ | ===== Samba tips ===== | ||
+ | |||
+ | === List available shares on a given host === | ||
+ | Replace host with the hostname or IP address of the server running samba shares | ||
+ | <code bash> | ||
+ | $ smbclient -L host | ||
+ | </ | ||
+ | |||
+ | Output will be something like this | ||
+ | < | ||
+ | Sharename | ||
+ | --------- | ||
+ | home Disk | ||
+ | shares | ||
+ | users | ||
+ | IPC$ IPC IPC Service () | ||
+ | |||
+ | Reconnecting with SMB1 for workgroup listing. | ||
+ | |||
+ | Server | ||
+ | --------- | ||
+ | |||
+ | Workgroup | ||
+ | --------- | ||
+ | MY_WORK | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | === Locate mount points === | ||
+ | |||
+ | Most of the time they are located at ''/ | ||
===== Alias ===== | ===== Alias ===== | ||
Create an alias using command | Create an alias using command | ||
- | < | + | < |
alias name=' | alias name=' | ||
</ | </ | ||
- | The alias is only in place while the user session is active. To make it permanent, write it in the .bashrc file in the home directory of the user. ([[http:// | + | The alias is only in place while the user session is active. To make it permanent, write it in the '' |
+ | |||
+ | You can reload the .bashrc file using : | ||
+ | |||
+ | <code bash> | ||
+ | $ source ~/.bashrc | ||
+ | #or | ||
+ | $ . ~/.bashrc | ||
+ | </ | ||
+ | |||
+ | ===== Programming Mouse Buttons ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ sudo apt install xbindkeys xvkbd | ||
+ | $ xev | grep ', button' | ||
+ | $ touch ~/ | ||
+ | $ nano ~/ | ||
+ | </ | ||
+ | |||
+ | // Sample File :// | ||
+ | |||
+ | < | ||
+ | # Send enter on thumb mouse button | ||
+ | "xvkbd -text ' | ||
+ | b:8 | ||
+ | </ | ||
+ | |||
+ | // Ccheck xvkbd for more syntax // | ||
===== Useful shell ===== | ===== Useful shell ===== | ||
Line 293: | Line 441: | ||
You can use for commands in the shell or use the ' | You can use for commands in the shell or use the ' | ||
- | < | + | < |
skx@lappy: | skx@lappy: | ||
a.JPG b.JPG c.JPG d.JPG | a.JPG b.JPG c.JPG d.JPG | ||
Line 311: | Line 459: | ||
08:21:02 | 08:21:02 | ||
</ | </ | ||
+ | ---- | ||
+ | |||
+ | === Mount === | ||
+ | List mounts | ||
+ | <code bash> | ||
+ | $ findmnt | ||
+ | </ | ||
+ | Target disk | ||
+ | <code bash> | ||
+ | $ sudo fdisk -l | ||
+ | Disk /dev/sda | ||
+ | [...] | ||
+ | Disk /dev/sdb | ||
+ | [...] | ||
+ | </ | ||
+ | Create mount point | ||
+ | <code bash> | ||
+ | $ sudo mkdir / | ||
+ | </ | ||
+ | Mount device | ||
+ | <code bash> | ||
+ | $ sudo mount /dev/sda1 / | ||
+ | </ | ||
+ | Unmount | ||
+ | <code bash> | ||
+ | $ sudo umount / | ||
+ | </ | ||
+ | [[https:// | ||
---- | ---- | ||
Line 322: | Line 498: | ||
---- | ---- | ||
+ | === tar === | ||
+ | Pack/Unpack tarball | ||
+ | <code bash> | ||
+ | #All the following commands are verbose (-v) and target a file archive (-f) | ||
+ | $ tar -xvf file.tar #Unpack tar (-x : extract) | ||
+ | $ tar -xvzf file.tar.gz #Unpack compressed (gzip) tar (-z : filter through gzip) | ||
+ | $ tar -cvf file.tar / | ||
+ | $ tar -cvzf file.tar / | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | ---- | ||
+ | |||
+ | === Samba === | ||
+ | |||
+ | <code bash> | ||
+ | sudo service smbd start/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== apt and dpkg ===== | ||
+ | |||
+ | ==== Fixing apt dependency problems ==== | ||
+ | |||
+ | This can fix some states in which apt is broken and refuses to update because some libraries fail : | ||
+ | |||
+ | <code bash> | ||
+ | $ dpkg --configure -a | ||
+ | $ apt --fix-broken install | ||
+ | </ | ||
===== List info ===== | ===== List info ===== | ||
+ | |||
+ | === Display all information === | ||
+ | |||
+ | <code bash> | ||
+ | $ inxi -F | ||
+ | </ | ||
+ | //Read the manual, inxi is a very powerful tool to quickly get an overview of a full hardware setup// | ||
=== Distrib === | === Distrib === | ||
- | < | + | < |
$ lsb_release -d | $ lsb_release -d | ||
</ | </ | ||
Line 334: | Line 548: | ||
=== CPU === | === CPU === | ||
Basic | Basic | ||
- | < | + | < |
$ lscpu | $ lscpu | ||
</ | </ | ||
Detailed, core-specific information, | Detailed, core-specific information, | ||
- | < | + | < |
$ cat / | $ cat / | ||
+ | </ | ||
+ | |||
+ | On Macs : | ||
+ | <code bash> | ||
+ | $ sysctl -n machdep.cpu.brand_string | ||
</ | </ | ||
=== Mounted devices === | === Mounted devices === | ||
- | < | + | < |
$ df -h | $ df -h | ||
</ | </ | ||
=== Kernel === | === Kernel === | ||
- | < | + | < |
$ uname -snrm | $ uname -snrm | ||
</ | </ | ||
Line 359: | Line 578: | ||
=== Kernel modules === | === Kernel modules === | ||
- | < | + | < |
$ lsmod | $ lsmod | ||
</ | </ | ||
=== Bash history === | === Bash history === | ||
- | < | + | < |
- | history | + | $ history |
</ | </ | ||
=== D-Bus/ | === D-Bus/ | ||
- | < | + | < |
- | gdbus | + | $ gdbus |
- | g-feet //gui history | + | $ g-feet //gui history |
</ | </ | ||
+ | === Motherboard information === | ||
+ | <code bash> | ||
+ | $ sudo dmidecode | grep -A3 ‘^System Information’ | ||
+ | </ | ||
+ | //dmidecode spurns out a lot of information if you want to query your system// | ||
+ | |||
+ | === Diagnostics & Tools === | ||
+ | |||
+ | <code bash> | ||
+ | $ uptime [load Average] | ||
+ | $ dmesg -T | tail [Kernel errors] | ||
+ | $ vmstat 1 [Virtual memory and detailed information] | ||
+ | $ mpstat -P ALL 1 [CPU state] | ||
+ | $ pidstat [processes] | ||
+ | $ free -m [memory] | ||
+ | $ atop [main overview] | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Debug & Logs ===== | ||
+ | |||
+ | ''/ | ||
+ | |||
+ | Check in ''/ | ||
+ | |||
+ | <code bash> | ||
+ | $ls -lart //inverted sorted by time. Last entry is latest modified | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Misc Ressources ===== | ||
+ | |||
+ | *[[https:// | ||
+ | *[[https:// |