Linux notes

From raju


useful HOWTOs and tutorials

sound related

Increase the Sound Level in a Video -

ffmpeg -i video-in.avi -vol 1536 -vcodec copy video-out.avi

Every 256 in vol increases sound by 100%. So in the above example, the sound will be increased by 600%.

wget tips

using wget to download a file via php script

wget -O NrrwRgn-0.32.vmb -q

Listing options in this order is more easy to remember (get the link, store it here and be quiet). Compare this to

wget -O csv-0.30.vmb -q

where the thought process is not as smooth.


execute external commands

To execute an external command in gdb

(gdb) help shell
Execute the rest of the line as a shell command.
With no arguments, run an inferior shell.
(gdb) shell date
Sun Jan 18 15:04:19 EST 2015

find usage articles

Articles on using find

List directories by size

To sort the directories by disk usage

rajulocal@hogwarts ~ % du -a -h --max-depth=1 | sort -h | tail -n 10
225M    ./compile_static_gdb_debian_way
228M    ./.local
370M    ./songs
501M    ./youtube_videos
849M    ./x
944M    ./.cache
1.2G    ./work
1.7G    ./.adobe
8.0G    ./software
15G     .

tips available on the net

add a string to the end of each line

We can use awk to add a given string to the end of each line in a file. For example,

% cat ~/x/junk21.txt
% cat ~/x/junk21.txt| awk '{print $0 " str .=$()-"}'
a str .=$()-
an str .=$()-
the str .=$()-
they str .=$()-
their str .=$()-

search the symbols

nm DebuggableExecutable -C

check if the DISPLAY variable is set correctly

Use "xset q" and check the error code. For example if it is working

% xset q
<output suppressed>
% echo $?

If it is not working

% xset q
xset:  unable to open display ""
% echo $?

What type of OS am I running?

Use OSTYPE environment variable to check the type of operating system.

% printenv | grep OS

or simply

% printenv OSTYPE   

top usage

  • Run in batch mode
 top -c -u [username] -b -n 1

-c -u [username] is optional -b is for batch mode -n 1 is to stop after one iteration

  • track the memory usage of a process over time
 top -b -p [pid] < /dev/null >& top.out &

Look at the VIRT field.

updatedb and locate

  • To generate the database
 updatedb -U <dir1> -l 0 -o <dir1.db>
 updatedb -U <dir2> -l 0 -o <dir2.db>
  • To search the database
 locate -d <dir1.db> -d <dir2.db> -e -i <expr>

Open a pdf at a specific page

To open at the 10th page of a pdf. Note that this is not same as opening it at page 10 by label.

    acroread /a page=10 file.pdf
    evince -i 10 file.pdf
    okular -p 10 file.pdf

To open at page 10 by label.

    evince -p 10 file.pdf

cat show filename

Use "tail -n +1" to show the filename when displaying its contents. For example

    tail -n +1 file1.txt file2.txt file3.txt


    ==> file1.txt <==
    <contents of file1.txt>
    ==> file2.txt <==
    <contents of file2.txt>
    ==> file3.txt <==
    <contents of file3.txt>

print the type of file system

    df -T /path/to/dir

This can tell if the directory is a local directory (ex:- ext4 filesytem) or a remote mount (ex:- nfs).

external links