Command Line
Command yang biasa dipakai di Linux
| Command | Contoh | Kegunaan |
|---|---|---|
| ls | ls -lat |
Menampilkan semua file dan direktori dalam direktori saat ini, dengan rincian lengkap dan diurutkan berdasarkan waktu modifikasi terbaru ke terlama |
| cd | cd /home/user/Documents |
Mengubah direktori kerja ke directory /Documents yang berada di directory /user, yang berada di directory /home |
| tail | tail -f /var/log/syslog |
Menampilkan baris terakhir dari file log sistem dan memperbarui tampilan setiap kali ada tambahan baru ke file tersebut |
| head | head -c 100 file.txt |
Menampilkan 100 byte pertama dari file.txt |
| cat | cat file.txt |
Menampilkan isi file |
| mkdir | mkdir new_directory |
Membuat direktori baru dengan nama : new_directory |
| mv | mv old_name.txt new_name.txt mv file.txt /new_directory/ |
Memindahkan atau mengganti nama file atau direktori |
| rm | rm file.txt, rm -r directory |
Menghapus file atau direktori |
| tar | tar -czvf archive.tar.gz directory/, tar -xzvf archive.tar.gz |
Mengompres atau mengekstrak file arsip |
| vi/vim/nano | nano file.txt, vim file.txt |
Mengedit file teks di file editor |
| sed | replace string | ——- |
| cut | cut text | ——- |
| find | find /home/user -name "file.txt" |
Mencari file atau direktori di dalam sistem |
| locate | search file / directory | ——- |
| cp | cp source.txt destination.txt atau cp -r dir1 dir | Menyalin file atau direktori |
| pwd | pwd |
Menampilkan direktori kerja saat ini |
| sudo | sudo apt update |
Menjalankan perintah dengan hak akses superuser |
| kill | kill 1234 |
Menghentikan proses yang berjalan, di mana 1234 adalah PID proses |
| chmod | chmod 755 script.sh |
Mengubah izin akses file atau direktori |
| chown | chown user:group file.txt |
Mengubah kepemilikan file atau direktori |
| df | df -h |
Menampilkan penggunaan disk |
| du | du -sh directory |
Menampilkan penggunaan disk oleh file atau direktori |
| ping | ping google.com |
Menguji konektivitas jaringan ke host lain |
| wget | wget http://example.com/file.zip |
Mengunduh file dari internet |
| grep | grep "pattern" file.txt |
Mencari pola teks di dalam file |
| history | history |
Menampilkan daftar perintah yang telah dijalankan sebelumnya |
| ssh | ssh user@hostname |
Mengakses mesin jarak jauh secara aman |
| scp | scp file.txt user@remote_host:/remote/directory/ |
Menyalin file antara mesin lokal dan mesin jarak jauh secara aman |
Beda echo dan cat
Use echo when you want to simply print a message or the value of a variable on the screen.
Use cat when you want to display the contents of a file on the terminal.
echo wkwkkwkwkw > access.log
cat access.log
tail access.log
head access.log
| Feature | echo | cat |
|---|---|---|
| Type | Built-in shell command | Separate executable program |
| Location | Integrated with the shell | Typically found in /bin/cat |
| Main Purposes | Display text or variable values | Display contents of filest |
| Use Case | Printing messages, debugging, variables | Displaying file content, concatenating files |