//Tips tagged alias
Want to show something on your machine to someone over the web? Don't copy it or upload it somewhere. Just run "webshare" and the current directory and everything beneath it will be served from a new web server listening on port 8000. When your pal is finished, hit control-c.
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'
Want to show something on your machine to someone over the web? Don't copy it or upload it somewhere. Just run "webshare" and the current directory and everything beneath it will be served from a new web server listening on port 8000. When your pal is finished, hit control-c.
A '\' mark before a command will ignore aliases. For example, you have alias
and want use ls without that --color option
$ \ls
alias ls='ls --color=auto'
and want use ls without that --color option
$ \ls
Add the following alias and function to your profile to be able to copy and paste files at the command line:
You can see below how this can be used:
ccopy(){ cp $1 /tmp/ccopy.$1; }
alias cpaste="ls /tmp/ccopy* | sed 's|[^\.]*.\.||' | xargs -I % mv /tmp/ccopy.% ./%"
You can see below how this can be used:
blackbird:~/tst tks1$ ls 1.txt 2.txt t1.tss t2.tss t3.tss blackbird:~/tst tks1$ ccopy 1.txt blackbird:~/tst tks1$ ccopy 2.txt
blackbird:~/tst tks1$ cd ../tst2 blackbird:~/tst2 tks1$ ls
blackbird:~/tst2 tks1$ cpaste
blackbird:~/tst2 tks1$ ls 1.txt 2.txt
ssh -l <login> -L <port>:<destination:port> <proxymachine> <local addy>
example
ssh -l foo -L 5000:192.168.5.2:443 192.168.1.1 https://localhost:5000/
Then go to https://localhost:<port>/ to get to destination's website; through the proxy machine.
example
ssh -l foo -L 5000:192.168.5.2:443 192.168.1.1 https://localhost:5000/
Then go to https://localhost:<port>/ to get to destination's website; through the proxy machine.
Create rc* alias for each init.d script. (can be include at /root/.bashrc)
SuSE distribution has a rc'service' for each init.d script that enables to easily start/stop service; but Debian and Ubuntu have not.
for service in `cd /etc/init.d/; ls`; do
alias "rc${service}"="/etc/init.d/${service}";
done
SuSE distribution has a rc'service' for each init.d script that enables to easily start/stop service; but Debian and Ubuntu have not.
I used to have 'em' as an alias for Emacs. One day, I wanted to edit a file and typed 'rm' instead of 'em', losing the file I had no backup of. So I set a common alias to keep me focused.
But sometimes this can be very annoying as you can imagine. By placing a backslash in front of a command, you "un-alias" it. This works for any alias you have set.
I still use the 'rm' alias, but switched to just 'e' for Emacs ;^)
alias rm='rm -i'
But sometimes this can be very annoying as you can imagine. By placing a backslash in front of a command, you "un-alias" it. This works for any alias you have set.
\rm *.c
I still use the 'rm' alias, but switched to just 'e' for Emacs ;^)
I use the following to list non-system users. It should be portable though won't work on systems without the getent command.
alias lsusers='getent passwd | tr ":" " " | awk "\$3 >= $(grep UID_MIN /etc/login.defs | cut -d " " -f 2) { print \$1 }" | sort'My little "iso2cd" alias. Not clean, but handy. The Burning device will be auto detected.
example call:
iso2cd debian_lenny_final.iso
alias iso2cd="cdrecord -s dev=`cdrecord --devices 2>&1 | grep "\(rw\|dev=\)" | awk {'print $2'} | cut -f'2' -d'=' | head -n1` gracetime=1 driveropts=burnfree -dao -overburn -v"
example call:
iso2cd debian_lenny_final.iso
alias iso2cd="cdrecord -s dev=`cdrecord --devices 2>&1 | grep "\(rw\|dev=\)" | awk {'print $2'} | cut -f'2' -d'=' | head -n1` gracetime=1 driveropts=burnfree -dao -overburn -v"
Counts files in the current directory and subdirectory
found is vserver-tools
alias lll='for i in *; do echo "`ls -1aRi $i | awk "/^[0-9]+ / { print $1 }" | sort -u | wc -l` $i" ; done | sort -n'
found is vserver-tools

