Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
lwc:programming:bash [2020/11/26 22:25] – created John Harrison | lwc:programming:bash [2024/09/27 12:48] (current) – [Superuser] John Harrison | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Comments:** | + | ==== Comments: |
- | + | ||
- | < | + | |
- | Put: : <' | + | |
- | + | ||
+ | Put: : ''<' | ||
before the block and put: | before the block and put: | ||
- | + | '' | |
- | COMMENTBLOCK_ORWHATEVERYOUWANTTOCALLME | + | |
after the block | after the block | ||
- | + | ==== DISPLAY SETTINGS: | |
- | \\ | + | |
- | + | ||
- | </ | + | |
- | **DISPLAY SETTINGS:** | + | |
* xrandr example: xrandr --output HDMI1 --mode 1280x1024 --right-of eDP1 | * xrandr example: xrandr --output HDMI1 --mode 1280x1024 --right-of eDP1 | ||
* change 1280x1024 display to 1600x1280: | * change 1280x1024 display to 1600x1280: | ||
* shift display down 1280 pixels: | * shift display down 1280 pixels: | ||
- | **FILE MANAGEMENT** | + | ==== FILE MANAGEMENT |
- | + | ||
- | \\ | + | |
Count # of files in a directory (recursively): | Count # of files in a directory (recursively): | ||
- | <HTML>< | + | <code> |
ll -R | grep -v " | ll -R | grep -v " | ||
- | </blockquote></ | + | </code> |
- | \\ | + | |
List files recursively by date: | List files recursively by date: | ||
- | <HTML>< | + | <code> |
find . -printf "%T@ %Tc %p\n" | sort -n | find . -printf "%T@ %Tc %p\n" | sort -n | ||
- | |||
printf arguments from man find: | printf arguments from man find: | ||
- | |||
%Tk: File's last modification time in the format specified by k. | %Tk: File's last modification time in the format specified by k. | ||
- | |||
@: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. | @: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. | ||
- | |||
c: locale' | c: locale' | ||
- | |||
%p: File's name. | %p: File's name. | ||
- | + | </code> | |
- | + | ||
- | \\ | + | |
- | + | ||
- | </blockquote></ | + | |
Add symbolic link to file (~/ | Add symbolic link to file (~/ | ||
- | <HTML>< | + | <code> |
for ELE in `find . -type d -print| awk 'NR > 1 {print}' | for ELE in `find . -type d -print| awk 'NR > 1 {print}' | ||
+ | </ | ||
- | \\ | ||
- | |||
- | </ | ||
change permissions of files recursively so group permissions match owner permissions: | change permissions of files recursively so group permissions match owner permissions: | ||
- | <HTML>< | + | <code> |
chmod -R g=u name-of-folder | chmod -R g=u name-of-folder | ||
- | </blockquote></ | + | </code> |
- | \\ | + | |
change permissions of directories or files only: | change permissions of directories or files only: | ||
- | <HTML>< | + | <code> |
find -type d -exec chmod 775 {} \; | find -type d -exec chmod 775 {} \; | ||
- | |||
- | |||
find -type f -exec chmod 664 {} \; | find -type f -exec chmod 664 {} \; | ||
- | + | </code> | |
- | </blockquote></ | + | |
- | \\ | + | |
copy files recursively, | copy files recursively, | ||
- | <HTML>< | + | <code> |
cd /source | cd /source | ||
- | |||
tar cf - * | ( cd /target; tar xfp -) | tar cf - * | ( cd /target; tar xfp -) | ||
+ | </ | ||
- | \\ | + | ==== Rip Audio from application using Pulseaudio (no Jack): |
- | + | ||
- | </ | + | |
- | **Rip Audio from application using Pulseaudio (no Jack):** | + | |
- | + | ||
- | \\ | + | |
- | + | ||
get index number of application audio: | get index number of application audio: | ||
- | |||
* pacmd | * pacmd | ||
* list-sink-inputs | * list-sink-inputs | ||
- | |||
assuming index is $INDEX: | assuming index is $INDEX: | ||
- | * pactl load-module module-null-sink sink_name=steam | + | * '' |
- | * pactl move-sink-input $INDEX steam | + | * '' |
- | * parec -d steam.monitor | sox -t raw -r 44k -sLb 16 -c 2 - / | + | * '' |
- | + | === Alternative: | |
- | + | * '' | |
- | + | * example: '' | |
- | + | * example cmd: '' | |
- | **VIDEO** | + | ==== VIDEO ==== |
- | + | ||
- | \\ | + | |
**transcode a video file so it is playable through Windows Media Player (Windows) and Quicktime (MacOS):** | **transcode a video file so it is playable through Windows Media Player (Windows) and Quicktime (MacOS):** | ||
- | \\ | + | <code> |
- | + | ||
- | + | ||
- | <HTML>< | + | |
ffmpeg -i INPUT_FILE -b 1500 -ab 384k -cropleft 20 -cropright 20 OUTPUT.mpg | ffmpeg -i INPUT_FILE -b 1500 -ab 384k -cropleft 20 -cropright 20 OUTPUT.mpg | ||
- | </blockquote></ | + | </code> |
- | **\\ | + | |
- | ** | + | |
- | **Record Desktop as Video:** | + | ==== Record Desktop as Video: |
The easy way is to use gtk-RecordMyDesktop, | The easy way is to use gtk-RecordMyDesktop, | ||
- | \\ | + | <code> |
- | + | ||
- | + | ||
- | <HTML>< | + | |
ffmpeg -f jack -ac 2 -ab 128k -i ffmpeg -acodec pcm_s16le -f x11grab -r 30 -s 320x240 -i :0.0+0,76 -vcodec libx264 -vpre lossless_ultrafast -threads 0 / | ffmpeg -f jack -ac 2 -ab 128k -i ffmpeg -acodec pcm_s16le -f x11grab -r 30 -s 320x240 -i :0.0+0,76 -vcodec libx264 -vpre lossless_ultrafast -threads 0 / | ||
- | </blockquote></ | + | </code> |
- | \\ | + | |
Notes: | Notes: | ||
Line 153: | Line 98: | ||
* if the output file exists, ffmpeg will ask you if you want to overwrite the old file. That's nice, but somehow this throws off the synchronization between the audio and the video. So if you want to overwrite an existing file, delete it first. | * if the output file exists, ffmpeg will ask you if you want to overwrite the old file. That's nice, but somehow this throws off the synchronization between the audio and the video. So if you want to overwrite an existing file, delete it first. | ||
- | **Position of Mouse Cursor:** | + | ==== Position of Mouse Cursor: |
- | + | <code> | |
- | + | ||
- | <HTML>< | + | |
mousepos.py (linux only) | mousepos.py (linux only) | ||
+ | </ | ||
- | + | ==== PRINTING | |
- | </ | + | |
- | \\ | + | |
- | + | ||
- | + | ||
- | **PRINTING** | + | |
- | + | ||
- | \\ | + | |
add PDF printer to ubuntu intrepid or jaunty (source): | add PDF printer to ubuntu intrepid or jaunty (source): | ||
Line 175: | Line 111: | ||
* sudo chmod +s / | * sudo chmod +s / | ||
* mkdir ~/PDF/ | * mkdir ~/PDF/ | ||
- | |||
bmeps seems to be the only way to make a transparent PDF from a PNG file. Directions for building here. | bmeps seems to be the only way to make a transparent PDF from a PNG file. Directions for building here. | ||
- | \\ | + | ==== PDF ==== |
- | + | ||
- | + | ||
- | **PDF** | + | |
- | + | ||
- | \\ | + | |
convert a grayscale PDF to B&W with Imagemagick: | convert a grayscale PDF to B&W with Imagemagick: | ||
- | + | <code> | |
- | + | ||
- | <HTML>< | + | |
convert -threshold 75% input.pdf output.pdf | convert -threshold 75% input.pdf output.pdf | ||
+ | </ | ||
+ | determine resolution of images inside a pdf: '' | ||
+ | ==== INTERNET ==== | ||
- | + | | |
- | \\ | + | |
- | + | | |
- | </ | + | * ssh -L 5901: |
- | **INTERNET** | + | * (in a separate terminal): xtightvncviewer -encodings tight localhost: |
- | + | * ssh to a host through another (jump) host | |
- | \\ | + | * use '' |
- | + | * also works for scp i.e. '' | |
- | + | ||
- | **ssh no password:** follow [[http:// | + | |
- | + | ||
- | \\ | + | |
- | + | ||
- | + | ||
- | **vpn on Linux 64 bit**: follow [[http:// | + | |
- | + | ||
- | \\ | + | |
- | + | ||
- | + | ||
- | **Remote Desktop (VNC through SSH tunnel)** | + | |
- | + | ||
- | | + | |
- | * (in a separate terminal): xtightvncviewer -encodings tight localhost: | + | |
**DHCP Server and Firestarter (on 12.04)** | **DHCP Server and Firestarter (on 12.04)** | ||
- | |||
* sudo apt-get install dhcp3-server | * sudo apt-get install dhcp3-server | ||
* sudo ln -s / | * sudo ln -s / | ||
Line 232: | Line 145: | ||
**Assign card a specific name:** | **Assign card a specific name:** | ||
- | + | <code> | |
- | <HTML>< | + | |
Example: | Example: | ||
- | |||
- | |||
udevinfo -a -p / | udevinfo -a -p / | ||
- | |||
- | |||
udevinfo -p / | udevinfo -p / | ||
- | |||
- | |||
ATTRS{modalias}==" | ATTRS{modalias}==" | ||
+ | </ | ||
+ | **Backup (tar) directory and subdirectories: | ||
- | \\ | + | <code> |
- | + | ||
- | </ | + | |
- | **Backup (tar) directory and subdirectories: | + | |
- | < | + | |
tar -cvzf mytarfile.tgz mydir/ | tar -cvzf mytarfile.tgz mydir/ | ||
+ | </ | ||
- | \\ | ||
- | |||
- | </ | ||
Backup database: | Backup database: | ||
- | <HTML>< | + | <code> |
- | + | ||
mysqldump --skip-lock-tables -h < | mysqldump --skip-lock-tables -h < | ||
+ | </ | ||
- | </ | + | FONTS: |
- | \\ | + | |
- | + | ||
- | + | ||
- | FONTS:\\ | + | |
* add ttf fonts in xubuntu by copying them into ~/.fonts (add the directory if it doesn' | * add ttf fonts in xubuntu by copying them into ~/.fonts (add the directory if it doesn' | ||
* install Monaco: | * install Monaco: | ||
**SWAPPINESS**: | **SWAPPINESS**: | ||
- | |||
- | |||
* find current value: cat / | * find current value: cat / | ||
* set on the fly: sudo sysctl vm.swappiness=10 | * set on the fly: sudo sysctl vm.swappiness=10 | ||
Line 281: | Line 176: | ||
Convert File Ascii --> Hex: | Convert File Ascii --> Hex: | ||
+ | [[https:// | ||
- | \\ | + | === check if port is in use === |
- | + | ||
- | + | ||
- | [[https:// | + | |
+ | < | ||
+ | ==== Superuser ==== | ||
+ | === Execute sudo cmd without needing to type password === | ||
+ | == Staying Safe == | ||
+ | - backup ''/ | ||
+ | - leave at least one terminal window open as root | ||
+ | - edit ''/ | ||
+ | == The Magic == | ||
+ | * create a wrapper script that does all your magic for you. Don't add sudo to the cmds in the wrapper script | ||
+ | * using '' | ||
+ | * to execute the cmd without password type '' | ||
+ | ===== Misc ===== | ||
+ | * write to dmesg: '' | ||
+ | * add timestamp to log entries that are piped. Add to pipe: '' | ||
+ | * '' | ||
+ | * remove package with all its dependencies. As root: '' | ||
+ | * [[https:// | ||
+ | * traverse through to see what is using disk space: '' | ||
+ | * find out what app is on a particular port: '' | ||