Some interesting 'powercommands' in linux (i didnt know any of them)
Posted 12-22-2005 at 05:35 AM by carl0ski
I felt the need to read through a big book about Bash commands so far here are some of my favourites
Alias command : allows assigning a long line of commands to a short phrase (alias shortcut='lengthycommand')
bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10 (a pain in the but to type)
but 'bit' isnt
#alias bit='bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10'
#bit suse.torrent
is now the same as
#bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10 suse.torrent
!! : automatically add the last command you typed
#ls /usr/src/
lists /usr/src
#!!linux
lists /usr/src/linux
TPUT Command allows you to alter terminal display.
for example
setb # "changes the background colour of you terminal screen"
setf # "changes the font colour of you terminal screen"
0-7 is support 0= black 7=white 2= green
smul "underlines all you text"
rmul "removes underlines of all you text
i made root permanently underlined green text with black backgroud by adding:
tput setb 0
tput setf 2
tput smul
to the file /etc/bashrc
Constantly change into a directory deep deep somewhere on your hdd? i do
cd /home/carl0ski/.kde/apps/
sure ~ variable helps but
CDPATH "a very powerful variable allows you to add directories to global access"
#export CDPATH=:.:/home/carl0ski/.kde/
now no matter where you are if you type cd apps guess where you end up :)
/home/carl0ski/.kde/apps#
more to follow
Cut
I hate it when posting a config file that it takes up muliple pages because of unneccessary # comments
Section "ServerFlags"
#DontZap # disable <Crtl><Alt><BS> (server abort)
#DontZoom # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
AllowMouseOpenFail # allows the server to start up even if the mouse does not work
EndSection
in this example i fetch info from xorg.conf send it to
cut , which -d looks for the # character and fetches everything before that (1st column) last that info is sent to
tr where -s shrinks extra spaces into one "" " "
cat /etc/X11/xorg.conf | cut -d '#' -f 1| tr -s "" " "
Section "ServerFlags"
AllowMouseOpenFail
EndSection
Pause equivilant in linux bash
SLEEP tseconds
#sleep 3; ls /
wait 3 seconds then list contents of / directory
Enter information into a prompt in linux bash
( commands, text, passwords etc )
(sleep 3; echo username; sleep 3; echo password; sleep 5; echo ping 127.0.0.1; sleep 3; echo "exit") | telnet hostname
Bash Rename Files (including spaces)
in this example i am renaming all file names
replacing ed, s0, 4e with Ed, S0, 4E
for i in *; do echo ${i}; a=`echo ${i}|replace ed Ed|replace s0 S0|replace 4e 4E`; mv -T "${i}" "${a}"; done
Source
ed - s04e13
Destination
Ed - S04E13
#store the Mplayer autocrop settings to $crop
#I wrote this line to help with Video encoding and mplayer playback
#
crop=$((sleep 5; echo "q")| mplayer /media/Videos/Films/The.Fifth.Element.1997.CD1.mkv -ss 600 -vf cropdetect|cut -d '(' -f 2|cut -d ')' -f 1|grep crop|tail -1)
#after the sleep period all commands in the brackets () will be launched through the pipe |
(sleep 5; echo "i've waited 5 seconds")|vi
#This will load VI text editor after 5 seconds "i've waited 5 seconds" will be typed into VI.
Alias command : allows assigning a long line of commands to a short phrase (alias shortcut='lengthycommand')
bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10 (a pain in the but to type)
but 'bit' isnt
#alias bit='bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10'
#bit suse.torrent
is now the same as
#bittorrent-curses --maxport 6666 --minport 7777 --maxuploadrate 10 suse.torrent
!! : automatically add the last command you typed
#ls /usr/src/
lists /usr/src
#!!linux
lists /usr/src/linux
TPUT Command allows you to alter terminal display.
for example
setb # "changes the background colour of you terminal screen"
setf # "changes the font colour of you terminal screen"
0-7 is support 0= black 7=white 2= green
smul "underlines all you text"
rmul "removes underlines of all you text
i made root permanently underlined green text with black backgroud by adding:
tput setb 0
tput setf 2
tput smul
to the file /etc/bashrc
Constantly change into a directory deep deep somewhere on your hdd? i do
cd /home/carl0ski/.kde/apps/
sure ~ variable helps but
CDPATH "a very powerful variable allows you to add directories to global access"
#export CDPATH=:.:/home/carl0ski/.kde/
now no matter where you are if you type cd apps guess where you end up :)
/home/carl0ski/.kde/apps#
more to follow
Cut
I hate it when posting a config file that it takes up muliple pages because of unneccessary # comments
Section "ServerFlags"
#DontZap # disable <Crtl><Alt><BS> (server abort)
#DontZoom # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
AllowMouseOpenFail # allows the server to start up even if the mouse does not work
EndSection
in this example i fetch info from xorg.conf send it to
cut , which -d looks for the # character and fetches everything before that (1st column) last that info is sent to
tr where -s shrinks extra spaces into one "" " "
cat /etc/X11/xorg.conf | cut -d '#' -f 1| tr -s "" " "
Section "ServerFlags"
AllowMouseOpenFail
EndSection
Pause equivilant in linux bash
SLEEP tseconds
#sleep 3; ls /
wait 3 seconds then list contents of / directory
Enter information into a prompt in linux bash
( commands, text, passwords etc )
(sleep 3; echo username; sleep 3; echo password; sleep 5; echo ping 127.0.0.1; sleep 3; echo "exit") | telnet hostname
Bash Rename Files (including spaces)
in this example i am renaming all file names
replacing ed, s0, 4e with Ed, S0, 4E
for i in *; do echo ${i}; a=`echo ${i}|replace ed Ed|replace s0 S0|replace 4e 4E`; mv -T "${i}" "${a}"; done
Source
ed - s04e13
Destination
Ed - S04E13
#store the Mplayer autocrop settings to $crop
#I wrote this line to help with Video encoding and mplayer playback
#
crop=$((sleep 5; echo "q")| mplayer /media/Videos/Films/The.Fifth.Element.1997.CD1.mkv -ss 600 -vf cropdetect|cut -d '(' -f 2|cut -d ')' -f 1|grep crop|tail -1)
#after the sleep period all commands in the brackets () will be launched through the pipe |
(sleep 5; echo "i've waited 5 seconds")|vi
#This will load VI text editor after 5 seconds "i've waited 5 seconds" will be typed into VI.