11 NOT SICK LINUX COMMANDS

1) CREATE A PDF VERSION OF A MANPAGE

man -t manpage | ps2pdf – filename.pdf

Quick and dirty version. I made a version that checks if a manpage exists (but it’s not a oneliner). You must have ps2pdf and of course Ghostscript installed in your box.

Enhancements appreciated :-)

2) BIND A KEY WITH A COMMAND

bind -x '"/C-l":ls -l'

   
   
   
   
the -x option is for binding to a shell command

3) USE FILE(1) TO VIEW DEVICE INFORMATION

file -s /dev/sd*

file(1) can print details about certain devices in the /dev/ directory (block devices in this example). This helped me to know at a glance the location and revision of my bootloader, UUIDs, filesystem status, which partitions were primaries / logicals, etc.. without running several commands.

See also:

file -s /dev/dm-* file -s /dev/cciss/*etc..

4) SINGLE USE VNC-OVER-SSH CONNECTION

ssh -f -L 5900:localhost:5900 your.ssh.server "x11vnc -safer -localhost -nopw -once -display :0";
vinagre localhost:5900

This command

1. SSH into a machine
2. Tunnels VNC port to your local computer (“-L 5900:localhost:5900″)
3. Runs a single use vnc server (“x11vnc -safer -localhost -nopw -once -display :0″)
4. Goes into the background (“-f”)
5. Runs VNC viewer on the local computer connecting to the remote machine via the newly created SSH tunnel (“vinagre localhost:5900″)

5) STOP FLASH FROM TRACKING EVERYTHING YOU DO.

for i in ~/.adobe ~/.macromedia ; do ( rm $i/ -rf ; ln -s /dev/null $i ) ; done

Brute force way to block all LSO cookies on a Linux system with the non-free Flash browser plugin. Works just fine for my needs. Enjoy.

6) A CHILD PROCESS WHICH SURVIVES THE PARENT’S DEATH (FOR SURE)

( command & )

Test scenario:

 

* Open xterm (or konsole, …)

* Start xeyes with: ( xeyes & )

* Close the xterminal

The xeyes process should be still running.

 

7) COMPARE COPIES OF A FILE WITH MD5

cmp file1 file2

8) BACKUP DELICIOUS BOOKMARKS

curl --user login:password -o DeliciousBookmarks.xml -O 'https://api.del.icio.us/v1/posts/all'

 Useful script to backup all your delicious bookmarks. With decilicious shutting down soon , it could be useful

9) RUN A PROGRAM TRANSPARENTLY, BUT PRINT A STACK TRACE IF IT FAILS

gdb -batch -ex “run” -ex “bt” ${my_program} 2>&1 | grep -v ^”No stack.”$

For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn’t have to mess around with core files.

The one downside is that it does smoosh your program’s stderr and stdout together.

10) BACK SSH FROM FIREWALLED HOSTS

ssh -R 5497:127.0.0.1:22 -p 62220 [email protected]

host B (you) redirects a modem port (62220) to his local ssh.

host A is a remote machine (the ones that issues the ssh cmd).

once connected port 5497 is in listening mode on host B.

host B just do a

ssh 127.0.0.1 -p 5497 -l user

and reaches the remote host’ssh. This can be used also for vnc and so on.

11) RENAME HTML FILES ACCORDING TO THEIR TITLE TAG

perl -wlne'/title>([^<]+)/i&&rename$ARGV,"$1.html"' *.html

The above one-liner could be run against all HTML files in a directory. It renames the HTML files based on the text contained in their title tag. This helped me in a situation where I had a directory containing thousands of HTML documents with meaningless filenames.

 

你可能感兴趣的:(html,linux,command,File,ssh,binding)