h1

the big bash commands list….

Dezember 5, 2007

Yes, this is my first attempt of creating a list of useful, everyday bash commands – as I find myself constantly in the situation looking for a specific bash command. If you’re unlucky, googleing the right command (especially if you don’t know what it’s called) can cost you several minutes if not hours.

So this will save me and hopefully you as well, the next time plenty of time. If you think there’s an important command still missing, which is more than likely, feel free to leave a comment with the command and a short explanation what it does.

Very special thanks to Bernd for the idea and his input! Thank you!

Basics:

cp test.txt /home/user/Desktop copies a txt file called test to the user’s Desktop

mv /home/test.txt /home/user/Desktop/ moves a txt file called test from the user’s home directory to the Desktop

sudo chmod -R 755 * changes the user rights recursively for the owner to read, write and execute – for group and world to read and execute. (this command requires root rights «sudo»)

sudo chmod -R u+w /home/user/data changes the user rights for the owner recursively to write and read of the directory /home/user/data

echo $USER prints the currently being used user name

sudo chown -R $USER.users ~/.kde/share/apps/kmail/mail changes the user ownership of the directory ~/.kde/share/apps/kmail/mail to the currently being used user name

ls -la ~/.kde/share/apps/ lists the content of a directory e.g ~/kde/share/apps/

ls | wc -l counts the files in a directory

cp test.txt{.bkp} copies text.txt to text.txt.bkp (creates a backup)

uname -a or uname -a | awk '{print $3}' lists your current kernel version number (awk ‚{print $3} prints only the kernel version, without its description)

Going deep:

perl -pi.bak -e 's/search/replace/' *.php replaces in all .php files the word „search“ with „replace“ and creates a backup file .bak e.g. index.php to index.php.bak

grep --color ; displays the search result in colour

grep -r searches /home/ searches recursively in /home/

pgrep firefox displays the process ID number of firefox or any application. useful to «kill» a process

sudo kill -9 pid pid = processID number ….. kill -9 kills the process (requires root rights)

sudo /etc/init.d/networking restart restarts the networking service

Mounting:

sudo mkdir hda1 creates a directory called „hda1“

sudo mount /dev/hda1 /mnt/hda1 mounts the harddisk hda1 into the directory /mnt/hda1

sudo umount /dev/sdb5 unmounts a device «sdb5» (in this case usb device)

sudo mount -t ntfs-3g /dev/hda5 /mnt/windows -o locale=de_DE.utf8 mounts a NTFS formatted harddisk read and writeable into /mnt/windows (this implies that the packages «ntfs-3g» & «ntfs-config» are installed)

sudo mount -t vfat /dev/hda1 /mnt/windows_c mounts a FAT formatted harddisk read and writeable into /mnt/windows_c

sudo blkid shows UUID number of a device

mount lists mounted devices

lsusb lists usb devices

sudo fdisk -l lists all mounted and unmounted harddisks or partitions

fuser -v /mount/point displays why a device can’t be unmounted and which process/user uses the device

Misc:

update-alternatives --config editor let’s you change the standard terminal editor (e.g from vim to nano)

ls -la /etc/alternatives/javac lists all java compilers

java -version displays the currently installed java version

msgfmt test.po -o test.mo compiles a language translation file (po) into a binary .mo file …. -o stands for output

sudo aptitude install language-pack-gnome-de installs a package from a repository (e.g. german gnome language pack)

sudo aptitude install tree installs a package called «tree»

tree -d -i (-i removes the 'tree') lists directories and subdirectories…
tree -d -i > dir.txt lists directories and subdirectories and saves the content into dir.txt

aptitude show ktorrent shows information on ktorrent and lists where it’s available (which repository)

MPLAYER:
mplayer -dumpstream "mms://a1505.v16544e.c16544.g.vm.akamaistream.net/7/1505/16544/v001/roomediaco1.download.akamai.com/16544/wm.roomedia/streamingVX/17056/1386/laptop_300.wmv?clipId=1386_computing_0030&channel=Netevents+TV&category=netevents+tv&site=vnudotnet%2fcomputing" -dumpfile laptop.wmv downloads a stream and saves it as «laptop.wmv»

6 Kommentare

  1. This is a very good idea. Thank you very much. I don’t have the capacity to remember these or I lack the courage to even try, I find myself needing to google these hints, ad nausium. I keep jewels like these you are sharing here at my del.icio.us/enotes9/bash (or ~/urpmi)

    If you or any of your readers are GNOMEies, a very useful one is in my stash if you follow my „website“ link in this comment


  2. Vibrant tile and flashy fixtures produce a look and feel that transcends any clear glass enclosure.
    Hopefully you may enjoy the exploration of style which you encounter
    in this section, acknowledging and appreciating the power of human adaptability
    and creativity in creating functional, aesthetically pleasing designs.


  3. Woah! I’m really loving the template/theme of this blog. It’s simple, yet effective.

    A lot of times it’s tough to get that „perfect balance“ between superb usability and appearance. I must say you’ve done a great job with this.
    Also, the blog loads extremely fast for me on Safari. Exceptional
    Blog!


  4. Moreover, players can play for free and for real money without any difficulties
    or problems in receiving the money. One therefore needs to keep formatting and re-formatting the
    i – Pod while switching from Mac to Windows etc.
    For the GPA customers information – you can move your Great Plains Accounting database from such platforms
    as Novell, Windows NT, Windows 2000 to Windows 2003 Server or even to Windows 2008 (we are in process of testing for this option, please check with us
    in few months, currently we are in February 2010).


  5. Hi there, just wanted to tell you, I enjoyed this
    post. It was funny. Keep on posting!


  6. Normally I do not learn post on blogs, but I wish to say that this write-up very pressured me to check out and do so!
    Your writing taste has been amazed me. Thanks, very nice article.



Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s

%d Bloggern gefällt das: