Posts Tagged Under: cheatsheet

Belajar Linux: Command Line Cheatsheet Part. 1

Beberapa command yang sering di gunakan untuk mengelola file, system, process dan lain-lain pada LINUX, saya coba rangkumkan di bawah ini:


File Commands

CommandDescription
lsList the content of the current directory
ls -RList the subdirectories recursively
ls -aList all the content, including hidden files
ls -list the content and its information
pwdOutput the current directory that you are in
cd folder1Change the working directory to folder1
cdReturn to the $Home directory
cd ..Go up a directory
cd -Return to the previous directory
cp source destinationCopy source to destination
cp -r source destinationCopy a folder recursively from source to destination
mv source destinationMove (or rename) a file from source to destination
rm file1Remove file1
rm -f file1Remove file1 without prompt
rm -r folderRemove a folder and its content recursively
mkdir foldernameCreate a new folder foldername
file file1Show the file type of file1
rmdir foldernameRemove an empty folder
cat file1 file2Concatenate file1 to file 2
cat > file1Concatenate standard input to file1
less file1View and paginate file1
head file1Show first 10 lines of file1
tail file1Show last 10 lines of file1
chmod 777 fileChange file permission of file to 777
chown user:group fileChange ownership of file to user and group group
ln -s source destinationCreate a symbolic link from source to destination

File Encryption and Compression

CommandDescription
gpg -c fileEncrypt file
gpg file.gpgDecrypt file.gpg
tar -cf archive.tar foo barCreate archive.tar from files foo and bar
tar -xf archive.tarExtract all files from archive.tar.
tar -czf archive.tar.gz foo barCreate archive.tar.gz from files foo and bar, with Gzip compression
tar -xzf archive.tar.gzExtract a tar using Gzip
tar -cjf archive.tar.bz2 foo barCreate archive.tar.bz2 from files foo and bar, using Bzip2 compression.
tar -xjf archive.tar.bz2Extract a tar using Bzip2
gzip file1Compress file1 and rename it to file1.gz
gzip -d file1.gzDecompress file1.gz

File Searching Commands

CommandDescription
grep pattern files Search for pattern in files
grep -r Recursive Search
grep -vInverted search
grep -i Case insensitive Search
grep -o Show matched part of file only
locate file1 Find file1
whereis command Find binary/source /manual for command
which appLocate a command for the app
look string file1 Display any lines in file1 which contain string as a prefix.
find /dir/ -user name Find files owned by name in dir
find /dir/ -mmin num Find files modifed less than num minutes ago in dir
find /dir/ -name name* Find files starting with name in dir

 

Read More

Belajar Linux: Command Line Cheatsheet Part. 2

Di bawah ini kelanjutan dari command line cheatsheet Part. 1.


System Commands

CommandDescription
uname -aShow system and kernel
head -n1 /etc/issueShow distribution
dateShow system date
uptimeShow system uptime
whoamiShow your username
wDisplay who is online
man commandShow manual for command
mountShow mounted filesystems
mount -o loop cdrom.iso /mnt/dirmount cdrom.iso at /mnt/dir
cat /proc/partitionsShow all partitions registered on the system
grep MemTotal /proc/meminfoShow RAM total seen by the system
grep "model name" /proc/cpuinfoShow CPU(s) info lspci -tv - Show PCI info
lsusb -tvShow USB info
!!Repeat the last command
exitLog out of current session

Process Management

CommandDescription
psShow snapshot of processes
topShow real time processes
kill pidKill process with id pid
pkill nameKill process with name name
killall nameKill all processes with names beginning name

Keyboard Shortcuts

CommandDescription
Ctrl + Shift + cCopy a highlighted text
Ctrl + cStop current command
Ctrl + Shift + vPaste a copied text
Ctrl + rStart a search
Ctrl + uCut from start of line
Ctrl + zSleep program
Ctrl + kCut to end of line
Ctrl + aGo to start of line
Ctrl + eGo to end of line

SSH

CommandDescription
ssh $USER@$HOSTConnect to $Host as $USER
ssh $USER@$HOST commandRun command on $HOST as $USER
ssh $USER@$HOST -p 1234Connect to $HOST as $USER on port 1234
scp file1 $USER@$HOST:file1Secure copy file1 from local machine to file1 at remote $HOST
scp $USER@$HOST:file1 file1Secure copy file1 from remote $HOST to file1 at local machine
scp -r foo $USER@$HOST:/barSecure copy the folder foo from local machine to the folder bar at remote $HOST

Package Installation

CommandDescription
dpkg -i package.debInstall a deb package
rpm -Uvh package.rpmInstall a rpm package

Disk Space

CommandDescription
df -hShow free space on mounted filesystems
df -iShow free inodes on mounted filesystems
du -h folderShow file usage of each folder in folder
du -sh folderShow the total file size of folder
fdisk -lShow disks partitions sizes and types (run as root)
freeShow memory and swap usage

 

Read More