Command Dasar di linux
-
Upload
jony-tyler -
Category
Documents
-
view
215 -
download
0
Transcript of Command Dasar di linux
-
8/7/2019 Command Dasar di linux
1/8
Command Dasar di linux & Daftar Direktori serta
shortcut pada linux
October 3, 2009 suryodesignLeave a commentGo to comments
Rate This
daftar dari direktori umum yang berada tepat di bawah direktori root (/) :
y /bin aplikasi biner pentingy /boot lokasi berkas konfigurasi untukboot.y /dev berkas peranti (device)y /etc berkas konfigurasi, skrip startup, dll (etc)y /home direktori pangkal (home) untuk penggunay /lib libraries yang diperlukan oleh sistemy
/lost+found menyediakan sisteml
ost+found
untuk berkas yang berada dibawahdirektori root (/)
y /media mount (memuat) removable media seperti CD-ROM, kamera digital, dlly /mnt untuk me-mountsistem berkasy /opt tempat lokasi untuk menginstal aplikasi tambahan (optional)y /proc direktori dinamis khusus yang menangani informasi mengenai kondisi
sistem, termasuk proses-proses (processes) yang sedang berjalan
y /root direktori pangkal untukroot, diucapkan slash-rooty /sbin sistem biner pentingy /sys mengandung informasi mengenai systemy /tmp berkas sementara (temporary)y /usr tempat aplikasi dan berkas yang sering digunakan oleh pengguna (users)y /var berkas variabel seperti log dan database
Terminal
Bekerja dengan baris perintah tidaklah tugas yang menakutkan seperti yang Anda pikir
sebelumnya. Tidak dibutuhkan pengetahuan khusus untuk mengetahui bagaimana
menggunakan baris perintah, ini adalah program seperti yang lainnya. Semua tugas di Linux
dapat diselesaikan menggunakan baris perintah, walaupun telah ada alat berbasis grafik untuk
semua program, tetapi kadang-kadang itu semua tidak cukup. Disinilah baris perintah akanmembantu Anda.
Terminal berada di Applications->Terminal . Terminal sering disebut command prompt atau
shell. Di masa lalu, hal ini adalah cara pengguna untuk berinteraksi dengan komputer, danpara pengguna Linux berpendapat bahwa penggunaan perintah melalui shell akan lebih cepat
dibanding melalui aplikasi berbasis grafik dan hal ini masih berlaku sampai sekarang. DisiniAnda akan mempelajari bagaimana menggunakan terminal.
Pindah ke mode Konsol
-
8/7/2019 Command Dasar di linux
2/8
Metode umum untuk mengakses baris perintah di Ubuntu adalah dengan menjalankanterminal (lihat Menjalankan Terminal di atas)
1. Gunaka shortcut Ctrl-Alt-F1 untuk pindah ke konsol satu.2. Untuk kembali ke mode Desktop, gunakan shortcut Ctrl-Alt-F7.
Ada tersedia enam buah konsol. Setiap konsol dapat diakses dengan shortcut Ctrl-Alt-F1 ke Ctrl-Alt-F6.
Menonaktifkan suara tit di mode Terminal
1. Jalankan sesi Terminal, pilih: Applications->Accessories->Terminal dari sistemmenu desktop.
2. Edit->Current Profile. Pilih tab General. Uncheck checkboxTerminalbell.Kegunaan awal dari terminal adalah sebagai peramban (browser) berkas dan kenyataannya
saat ini masih digunakan sebagai peramban berkas, di saat lingkungan berbasis grafik tidak
tersedia. Anda dapat menggunakan terminal sebagai peramban berkas untuk melihat berkasdan membatalkan perubahan yang telah dibuat.
Perbedaan terminal pada setiap versi ubuntu
In Gnome (Ubuntu)
The terminal can be found at Applications menu -> Accessories -> Terminal.
In Xfce (Xubuntu)
The terminal can be found at Applications menu -> System -> Terminal.
In KDE (Kubuntu)
The terminal can be found at KMenu -> System -> Terminal Program (Konsole).
Perintah umum di terminal
Menilik Direktori ls
Perintah ls (LiSt) melihat daftar berkas dalam suatu direktori.
Membuat Direktori: mkdir (nama direktori)
Perintah mkdir (MaKeDIRectory) untuk membuat direktori.
Mengubah Direktori: cd (/direktori/lokasi)
Perintah cd perintah (ChangeDirectory) akan mengubah dari direktori Anda saat ini
ke direktori yang Anda tentukan.
-
8/7/2019 Command Dasar di linux
3/8
Menyalin Berkas/Direktori: cp (nama berkas atau direktori) (ke direktori atau nama berkas)
Perintah cp (CoPy) akan menyalin setiap berkas yang Anda tentukan. Perintah cp -r
akan menyalin setiap direktori yang Anda tentukan.
Menghapus Berkas/Direktori: rm (nama berkas atau direktori)
Perintah rm perintah (ReMove) akan menghapus setiap berkas yang Anda tentukan.
Perintah rm -rfakan menghapus setiap direktori yang Anda tentukan.
Ganti Name Berkas/Direktori mv (nama berkas atau direktori)
Perintah mv (MoVe) akan mengganti nama/memindahkan setiap berkas atau direktori
yang Anda tentukan.
Mencari Berkas/Direktori: mv (nama berkas atau direktori)
Perintah locate akan setiap nama berkas yang anda tentukan yang ada di dalam
komputer. Perintah ini menggunakan indeks dari berkas dalam sistem Anda untuk
bekerja dengan cepat: untuk memutakhirkan indeks ini jalankan perintah updatedb.
Perintah ini berjalan otomatis setiap hari, apabila komputer Anda nyala terus setiap
hari. Dan perintah ini harus dijalankan dengan hak istimewa administratif (lihatRoot
Dan Sudo).
File & Directory Commands
y pwd: The pwd command will allow you to know in which directory youre located(pwd stands for print working directory).Example: pwd in the Desktop directory
will show ~/Desktop. Note that the Gnome Terminal also displays this information
in the title bar of its window.y ls: The ls command will show you the files in your current directory. Used with
certain options, you can see sizes of files, when files were made, and permissions of
files.Example: ls ~ will show you the files that are in your home directory.
y cd: The cd command will allow you to change directories. When you open a terminalyou will be in your home directory. To move around the file system you will use cd.Examples:
o To navigate into the root directory, use cd /o To navigate to your home directory, use cd orcd ~o To navigate up one directory level, use cd ..o To navigate to the previous directory (or back), use cd -o To navigate through multiple levels of directory at once, specify the full
directory path that you want to go to. For example, use, cd /var/www to godirectly to the /www subdirectory of /var/. As another example, cd
~/Desktop will move you to the Desktop subdirectory inside your home
directory.
y cp: The cp command will make a copy of a file for you.Example: cp file foo willmake a exact copy of file and name it foo, but the file file will still be there. If
you are copying a directory, you must use cp -r directory foo (copy recursively).y mv: The mv command will move a file to a different location or will rename a file.
Examples are as follows: mv file foo will rename the file file to foo.mv foo
-
8/7/2019 Command Dasar di linux
4/8
~/Desktop will move the file foo to your Desktop directory but will not rename it.You must specify a new file name to rename a file.
o To save on typing, you can substitute ~ in place of the home directory.o Note that if you are using mv with sudo you can use the ~ shortcut, because
the terminal expands the ~ to your home directory. However, when you open a
root shell with sudo -i orsudo -s, ~ will refer to the root accounts home
directory, not your own.y rm: Use this command to remove or delete a file in your directory.y rmdir: The rmdir command will delete an empty directory. To delete a directory and
all of its contents recursively, use rm -r instead.
y mkdir: The mkdir command will allow you to create directories.Example: mkdirmusic will create a directory called music .
y man: The man command is used to show you the manual of other commands. Tryman man to get the man page forman itself. See the Man & Getting Help
section down the page for more information.
System Information Commands
y df: The dfcommand displays filesystem disk space usage for all mounted partitions.df -h is probably the most useful it uses megabytes (M) and gigabytes (G) instead
of blocks to report. (-h means human-readable)
y du: The du command displays the disk usage for a directory. It can either display thespace used for all subdirectories or the total for the directory you run it on.Example:
user@users-desktop:~$ du /media/floppy1032 /media/floppy/files1036/media/floppy/user@users -desktop:~$ du -sh /media/floppy1.1M/media/floppy/
y -s means Summary and -h means Human Readabley free: The free command displays the amount of free and used memory in the system.
free -m will give the information using megabytes, which is probably most useful
for current computers.
y top: The top command displays information on your Linux system, running processesand system resources, including CPU, RAM & swap usage and total number of tasks
being run. To exit top, press q.
y uname -a: The uname command with the -a option prints all system information,including machine name, kernel name & version, and a few other details . Most useful
for checking which kernel youre using.
y lsb_release -a: The lsb_release command with the -a option prints versioninformation for the Linux release youre running, for example:
user@computer:~$ lsb_release -aNo LSB modules are available.Distributor ID:UbuntuDescription: Ubuntu 6.06 LTSRelease: 6.06Codename:dapper
y ifconfig reports on your systems network interfaces.Adding A New User
-
8/7/2019 Command Dasar di linux
5/8
y adduser newuser command will create a new general user called newuser onyour system, and to assign a password fort e newuser account usepasswd
newuser .
Opti ns
The default behaviour for a command may usually be modified by adding aoptionto the
command. The ls command for example has an -s option so thatls -s willinclude file si es
in the listing. There is also a -h option to getthose si es in a human readable format.
Options can be grouped in clusters sols -sh is exactly the same command as ls -s -h.
Most options have a long version, prefixed with two dashes instead of one, so evenls sizehuman-readableis the same command.
Man and getting help
man command, info commandand commandhelp are the mostimportanttools atthe
command line.
Nearly every command and application in Linux will have a man (manual) file, so finding
them is as simple as typing man command"to bring up a longer manual entry forthespecified command. For example,man mv will bring up the mv (Move) manual.
Move up and down the man file with the arrow keys, and quit backto the command prompt
with q .
man man will bring up the manual entry forthe man command, which is a good place to
start!
man intro is especially useful it displays the Introduction to user commands which is a
well written, fairly briefintroduction to the Linux command line.
There are also info pages, which are generally more in-depth than man pages. Try infoinfo forthe introduction to info pages.
Some software developers preferinfoto man (forinstance, GNU developers), so if you find
a very widely used command or app that doesnt have aman page, its worth checking for an
info page.
Virtually all commands understand the -h (orhelp) option which will produce a short usage
description ofthe command and its options, then exit backto the command prompt. Tryman -h orman help to see this in action.
Caveat: It i
le (
t are) thata rogram doesnt nderstand the-h option tomeanhelp. Forthisreason, heckforamanorinfopage first,and try thelongoptionhelp
efore
-h.
Searching for man files
-
8/7/2019 Command Dasar di linux
6/8
If you arent sure which command or application you need to use, you can try searching theman files.
y man -kfoo will search the man files forfoo. Try man -k nautilus to see how thisworks.
o Note that this is the same as doing apropos command.y man -ffoo searches only the titles of your systems man files . Try man -f gnome,
for example.
o Note that this is the same as doing whatis command.
Other Useful Things
Prettier Manual Pages
Users who have Konquerorinstalled will be pleased to find they can read and search man
pages in a web browser context, prettified with their chosen desktop fonts and a little colour,by visiting man:/command in Konquerors address bar. Some people might find this lightens
the load if theres lots of documentation to read/search.
Pasting in commands
Often, you will be referred to instructions that require commands to be pasted into the
terminal. You might be wondering why the text youve copied from a web page using ctrl+C
wont paste in with ctrl+V. Surely you dont have to type in all those nasty commands andfilenames? Relax. Middle Button Click on your mouse (both buttons simultaneously on a
two-button mouse) or Right Click and select Paste from the menu.
Save on typing
Up Arroworctrl+p
Scrolls through the commands youve entered previously.
Down
Arrow or
ctrl+n
Takes you back to a more recent command.
Enter When you have the command you want.
tabA very useful feature. It autocompletes any commands or filenames, if theres
only one option, or else gives you a list of options.
ctrl+r
Searches for commands youve already typed. When you have entered a very
long, complex command and need to repeat it, using this key combination and
then typing a portion of the command will search through your command history.When you find it, simply press Enter.
History
The history command shows a very long list of commands that you have typed.
Each command is displayed next to a number. You can type !x to execute a
previously typed command from the list (replace the X with a number). If you
history output is too long, then use history | less for a scrollable list.
Change the text
-
8/7/2019 Command Dasar di linux
7/8
The mouse wont work. Use the Left/Right arrow keys to move around the line.
When the cursor is where you want it in the line, typing inserts text ie it doesnt overtypewhats already there.
ctrl+a orHome Moves the cursor to the startof a line.
ctrl+e orEnd Moves the cursor to the endof a line.
ctrl+b Moves to the beginning of the previous or current word.
ctrl+k Deletes from the current cursor position to the end of the line.
ctrl+u Deletes the whole of the current line.
ctrl+w Deletes the word before the cursor.
Dan berikut adalah perintah linux dari seorang blogger pecinta linux jg
cd x atau cd /x == masuk ke direktori x
cd .. atau cd ../ atau cd/.. == pindah ke direktori satu level di bawah
x lalu [tab] [tab] == berguna untuk mengetahui perintah apa saja yang tersedia yangberawalan huruf x
adduser == untuk menambahkan user baru
ls atau dir == untuk melihat isi suatu direktori
cat == untuk melihat isi dari suatu file text
mv x y == untuk memindahkan atau merename file x ke file y
cp x y == untuk mengkopi file x ke file y
rm x == untuk menghapus file x
mkdir x == untuk membuat direktori x
rmdir x == untuk menghapus direktori xrm -r x == untuk menghapus direktori x beserta seluruh isinya
rm p == untuk menghapus paket tertentudf atau df x == untuk mengetahui space kosong dalam device x
top == untuk mengetahui status memori (tekan q untuk quit )
man x == untuk mengetahui keterangan manual dari suatu perintah
less x == untuk melihat isi dari suatu file text
echo x == untuk mencetak isi dari suatu file x ke screen
mc == untuk menghidupkan Norton Commander dalam Linux (sangat berguna dan
memudahkan bagi newbie)
mount == untuk menghidupkan suatu device spt cdrom
halt == untuk shutdownreboot atau [ctl + alt + del] == untuk reboot
chmod == untuk mengubah permission suatu file
ls -l x == untuk melihat isi suatu direktori secara rinciln -s x y == untuk membuat link dari suatu file x ke file y
find x -name y -print == untuk menemukan file y, dengan mencari mulai dari direktori x dantampilkan hasilnya pada layar
ps == untuk melihat seluruh proses yang sedang berjalan
kill x == untuk mematikan proses x (x adalah PID di dalam ps)
-
8/7/2019 Command Dasar di linux
8/8
[alt] + F1 F7 == untuk berpindah dari terminal 1 7 (ciri khas Linux)lilo == untuk membuat boot disk
startx == untuk menjalankan X-Windows
[ctl] + [alt] + [backspace] == untuk keluar dari X-Windows jika terjadi trouble
[ctl] + [alt] + F1 F6 == untuk pindah dari satu terminal ke terminal lain dalam X-Windows
xf86Config == untuk mengeset X (primitif) dalam text mode
Xconfigurator == sama seperti di atas
source : http://www.ubuntu-id.org/doc/edgy/xubuntu/desktopguide/id/linux-basics.html ,
https://help.ubuntu.com/community/UsingTheTerminal?action=show&redirect=BasicCommands