This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
quick_command_list [2014/05/22 18:42] k2patel [sed to search and replace search text and number following] |
quick_command_list [2022/05/16 20:05] (current) k2patel [remove comments and blank lines from output] |
||
---|---|---|---|
Line 333: | Line 333: | ||
grep -v -e '^#\|^\W*$' | grep -v -e '^#\|^\W*$' | ||
</code> | </code> | ||
+ | OR | ||
+ | <code bash> | ||
+ | grep '^[[:blank:]]*[^[:blank:]#;]' $file | ||
+ | </code> | ||
==== Calculating Date ==== | ==== Calculating Date ==== | ||
Line 391: | Line 394: | ||
cat file.ps | ghostview -landscape - | cat file.ps | ghostview -landscape - | ||
</code> | </code> | ||
+ | |||
+ | ==== Print yum environment ==== | ||
+ | <code bash> | ||
+ | python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)' | ||
+ | </code> | ||
+ | |||
+ | ==== Perl Local::lib ==== | ||
+ | Simple easy way to install perl module locally. | ||
+ | |||
+ | Simply install local::lib | ||
+ | |||
+ | In order to install module locally use command as shown below. | ||
+ | <code bash> | ||
+ | perl -MCPAN -Mlocal::lib -e 'CPAN::install(threads)' | ||
+ | </code> | ||
+ | |||
+ | ==== Clearing cache linux ==== | ||
+ | Make sure you run **//sync//** command before each command here.\\ | ||
+ | Alternatively you can use | ||
+ | <code bash> | ||
+ | sysctl -w vm.drop_caches=<number> | ||
+ | </code> | ||
+ | |||
+ | **Free Dentries, Inodes and pagecache from cache memory** | ||
+ | <code bash> | ||
+ | echo 3 > /proc/sys/vm/drop_caches | ||
+ | </code> | ||
+ | |||
+ | **Free Inodes and Dentries from cache memory** | ||
+ | <code bash> | ||
+ | echo 2 > /proc/sys/vm/drop_caches | ||
+ | </code> | ||
+ | *Free PageCache from memory** | ||
+ | <code bash> | ||
+ | echo 1 > /proc/sys/vm/drop_caches | ||
+ | </code> | ||
+ | |||
+ | Writing to /proc/sys/vm/drop_caches allows one to request the kernel immediately drop as much clean cached data as possible.\\ | ||
+ | This will usually result in some memory becoming more obviously available; however, under normal circumstances this should not be necessary.\\ | ||
+ | BE WARNED that using vm.drop_caches can cause a deadlock if the system is under heavy memory and I/O load!!! | ||
+ | |||
+ | ==== Ping packet size ==== | ||
+ | <code bash> | ||
+ | ping -v -M do -s 8064 192.168.1.1 | ||
+ | </code> | ||
+ | |||
+ | ==== Remove file with ASCII Name ==== | ||
+ | |||
+ | Simplest thing to do is use built in functionality to search and remove in command. | ||
+ | Here is the file i've on my machine. | ||
+ | <code bash> | ||
+ | �^? | ||
+ | </code> | ||
+ | |||
+ | which translate to //''$'\250\177'// <br> | ||
+ | So check or list all the files with ascii in it. | ||
+ | <code bash> | ||
+ | ls [^[:ascii:]]* | ||
+ | </code> | ||
+ | |||
+ | now to remove | ||
+ | <code bash> | ||
+ | rm [^[:ascii:]]* | ||
+ | </code> | ||
+ | |||
+ | :!: Regex can be modified to list all matching file before removal. | ||
+ | |||
+ | ==== Testing connection or port without any software ==== | ||
+ | In linux proper way to test tcp or udp port connection without any software installed should be creating dev node. | ||
+ | |||
+ | <code bash> | ||
+ | /dev/<proto>/<host>/<port> | ||
+ | </code> | ||
+ | |||
+ | out put can be redirected to tty with help of cat. | ||
+ | <code bash> | ||
+ | cat < /dev/tcp/k2patel.in/3306 | ||
+ | </code> | ||
+ | |||
+ | ==== Setting id tag on mp3 ==== | ||
+ | Setting mp3 tag on multiple file based on filename as song name.\\ | ||
+ | Same artist. | ||
+ | <code bash> | ||
+ | while read k2; do id3tag -a'xyz guru' -A'SuperSpeed' -s"${k2%%.*}" -y'2021' "${k2}" ; done < <(ls *.mp3) | ||
+ | </code> | ||
+ | |||
+ | ==== FFMpeg Conversion of 4K ==== | ||
+ | I had issue of no audio while playing file over DLNA.\\ | ||
+ | I've did the transcoding so it can play audio on my Phillips 4K TV. | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -i <input_file>.mp4 \ | ||
+ | -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:5 -map 0:12 \ | ||
+ | -c:v copy \ | ||
+ | -c:a:0 truehd -strict -2 \ | ||
+ | -c:a:1 ac3 \ | ||
+ | -c:s copy \ | ||
+ | <output_file>.mkv | ||
+ | </code> | ||
+ | OR | ||
+ | <code bash> | ||
+ | ffmpeg -i old_file.mp4 \ | ||
+ | -map 0:0 -map 0:1 -map 0:3 -map 0:5 \ | ||
+ | -c:v copy \ | ||
+ | -c:a:0 ac3 \ | ||
+ | -c:s copy \ | ||
+ | new_file.mp4 | ||
+ | </code> | ||
+ | OR | ||
+ | <code bash> | ||
+ | ffmpeg -i old_file.mkv \ | ||
+ | -map 0:0 -map 0:1 -map 0:2 \ | ||
+ | -c:v copy \ | ||
+ | -c:a:0 ac3 \ | ||
+ | -c:s copy \ | ||
+ | -disposition:s:0 forced \ | ||
+ | new_file.mkv | ||
+ | </code> | ||
+ | |||
+ | - First thing list all mapping on your existing file using 'ffmpeg -i <file> | ||
+ | - Select all streams using map you would like to copy to your new file. | ||
+ | - each map should be listed using map so i selected only 6 out of 12. | ||
+ | - After that specify wich codecs to use. | ||
+ | - in -c:v i'm copying video as is. | ||
+ | - in -c:a:0 i'm converting audio to truehd | ||
+ | - in -c:a:1 i'm also adding second audio stream which is ac3. | ||
+ | - in -c:s i'm copying subtitles. |