Difference between revisions of "Linux shell/Commands"
Line 46: | Line 46: | ||
sudo apt-get install parcellite | sudo apt-get install parcellite | ||
then in the settings check "use primary" and "synchronize clipboards" | then in the settings check "use primary" and "synchronize clipboards" | ||
= Generate random password = | = Generate random password = |
Revision as of 20:52, 29 December 2014
One liners
- df -h displays filesystem disk space usage for all mounted partitions
- du -sh displays the disk usage for a directory, -s is for summary
- free -m displays the amount of free and used memory in the system
- lsb_release -a prints version information for the Linux release you're running
- tload -draws system load on text based graph
Copy with progress bar
- rsync and cp
- rsync -aP - copy with progress can be also aliased alias cp='rsync -aP'
- cp -rv old-directory new-directory - shows progress bar
- PV does not preserve permissions and does not handle attributes
- pv ~/kali.iso | cat - /media/usb/kali.iso equals cp ~/kali.iso /media/usb/kali.iso
- pv ~/kali.iso > /media/usb/kali.iso equals cp ~/kali.iso /media/usb/kali.iso
- pv access.log | gzip > access.log.gz shows gzip compressing progress.
PV can be imagined as CAT command piping '|' output to another command with a bar progress and ETA times. -c makes sure one pv output is not use to write over to another, -N creates a named stream. Find more at How to use PV pipe viewer to add progress bar to cp, tar, etc..
$ pv -cN source access.log | gzip | pv -cN gzip > access.log.gz source: 760MB 0:00:15 [37.4MB/s] [=> ] 19% ETA 0:01:02 gzip: 34.5MB 0:00:15 [1.74MB/s] [ <=> ]
Tail log files
tail-f-the-output-of-dmesg or install multitail
tail -f /var/log/{messages,kernel,dmesg,syslog}
- old school but not perfectwatch 'dmesg | tail -50'
- approved by man dmesgwatch 'sudo dmesg -c >> /tmp/dmesg.log; tail -n 40 /tmp/dmesg.log'
- tested, but experimental
Useful packages
- ARandR Screen Layout Editor - 0.1.7.1
Copy and Paste in terminal
In Linux X graphical interface this works different then in Windows you can read more in X Selections, Cut Buffers, and Kill Rings. When you select some text this becomes the Primary selection (not the Clipboard selection) then Primary selection can be pasted using the middle mouse button. Note however that if you close the application offering the selection, in your case the terminal, the selection is essentially "lost".
Option 1 works in X
- select text to copy then use your mouse middle button or press a wheel
Option 2 works in Gnome Terminal
- Ctrl+Shift+C -to copy
- Ctrl+Shift+V or Shift+Insert -to paste
Option 3 Install Parcellite GTK+ clipboard manager
sudo apt-get install parcellite
then in the settings check "use primary" and "synchronize clipboards"
Generate random password
cat /dev/urandom|tr -dc "a-zA-Z0-9"|fold -w 48|head -n1