Lewati ke konten
Kembali ke Blog

Cara Menggunakan Terminal Linux untuk Pemula

Β· Β· 3 menit baca

Terminal adalah cara powerful untuk berinteraksi dengan sistem Linux. Mari pelajari command-command dasar.

Opening Terminal

Keyboard Shortcut

Ctrl + Alt + T    - Open terminal
Ctrl + Shift + T  - New tab
Ctrl + D          - Close terminal

Navigasi File System

Current Location

# Print working directory
pwd

List Files

# List files
ls

List with details

ls -l

List all including hidden

ls -la

List sorted by time

ls -lt

Change Directory

# Go to directory
cd Documents

Go to home

cd ~ cd

Go up one level

cd ..

Go to previous directory

cd -

File Operations

Create Files and Folders

# Create empty file
touch filename.txt

Create directory

mkdir foldername

Create nested directories

mkdir -p folder1/folder2/folder3

Copy, Move, Delete

# Copy file
cp source.txt destination.txt

Copy directory

cp -r folder1 folder2

Move/rename

mv oldname.txt newname.txt mv file.txt /path/to/destination/

Delete file

rm filename.txt

Delete directory

rm -r foldername

Delete with confirmation

rm -i filename.txt

Viewing File Contents

Basic Commands

# View entire file
cat filename.txt

View with pagination

less filename.txt

View first 10 lines

head filename.txt head -n 20 filename.txt

View last 10 lines

tail filename.txt tail -f logfile.txt # Follow updates

Finding Files

find Command

# Find by name
find /path -name "filename.txt"

Find by extension

find . -name "*.txt"

Find by size

find . -size +10M

Find modified in last 7 days

find . -mtime -7

grep Command

# Search text in file
grep "search_term" filename.txt

Search recursively

grep -r "search_term" /path/to/folder

Case insensitive

grep -i "search_term" filename.txt

Show line numbers

grep -n "search_term" filename.txt

User Management

User Info

# Current user
whoami

User details

id

Switch user

su username

Run as root

sudo command

System Information

Basic Info

# System info
uname -a

Disk usage

df -h

Memory usage

free -h

Running processes

top htop

Package Management

APT (Ubuntu/Debian)

# Update package list
sudo apt update

Upgrade packages

sudo apt upgrade

Install package

sudo apt install packagename

Remove package

sudo apt remove packagename

File Permissions

Understanding Permissions

-rwxr-xr-x
β”‚β””β”¬β”˜β””β”¬β”˜β””β”¬β”˜
β”‚ β”‚  β”‚  └── Others (r-x = read, execute)
β”‚ β”‚  └───── Group (r-x = read, execute)
β”‚ └──────── Owner (rwx = read, write, execute)
└────────── File type (- = file, d = directory)

Changing Permissions

# Add execute permission
chmod +x script.sh

Set specific permissions

chmod 755 script.sh

Change owner

chown user:group filename

Kesimpulan

Menguasai terminal Linux membuka banyak kemungkinan untuk automation dan efficient workflow.

Ditulis oleh

Hendra Wijaya

Tinggalkan Komentar

Email tidak akan ditampilkan.