Basic Linux commands Linux thiab lub qhov rais Operating Systems

This writing is useful for those that wish to get started with Linux commands. Here you will find the most common commands that are used in Linux.

If you would like to run Linux commands on Qhov rais then install Cygwin. Cygwin is a Linux layer on top of Windows that allows you to use Linux commands in Windows.

Yog hais tias koj nruab Cygwin rau lub qhov rais ces lub neej ntawd txoj kev thaum koj pib lub Cygwin davhlau ya nyob twg yuav tsum:

C:\cygwin64\home\{username}

 

Tsim tshiab notepad ntaub ntawv piv txwv li

touch textfile.txt

 

Hloov directory

cd {directory path\name}

 

List directory content in long format ( -l ) including hidden files and directories ( -ib tug )

ls -l -a

ls -al

 

Order files and directories by the time they were last modified

ls -t

 

List directory with pause and scrolling

ls -l | less

 

Qhia tam sim no qhov chaw nyob (print working directory)

pwd

 

Extract kawg 100 lus ntawm ib cov ntaub ntawv

tail -100 {filename.extension}

 

Extract thawj 100 kab ntawm ib cov ntaub ntawv

head -100 {filename.extension}

 

Luam ib cov ntaub ntawv

cp {source} {destination}

 

Txav mus rau ib cov ntaub ntawv

mv {source} {destination}

 

Ua ib tug tshiab directory

mkdir {new directory name}

 

Rho tawm cov ntaub ntawv

rm {filename}

 

Delete an empty directory

rmdir {directory to remove}
rm -d{directory to remove}

 

Delete directory and its contents

rm -r {directory to remove}
rm -R{directory to remove}

 

Txheeb tus txheem ntawm ib cov ntaub ntawv

sort {filename to sort}

 

Tshem tawm duplicate nkag rau hauv ib cov ntaub ntawv

uniq {filename to remove duplicates}

 

Hlob ntaub ntawv

gzip {filename}

 

Hlob directory

gzip -r {directory name}

 

Suav cov xov tooj ntawm kab thiab lus nyob rau hauv ib phau ntawv cov ntaub ntawv

wc {filename}

 

Search text within files for matching string pattern (case sensitive)

grep 'word' {filename}

 

Search text within files for matching string pattern (case insensitive)

grep -i 'word' {filename}

 

Search with a directory

grep -R Arctic /home/ccuser/workspace/geography

 

Zaub ntsiab lus ntawm ib phau ntawv cov ntaub ntawv

cat

 

sed stream editor (similar to find and replace)

sed 's/snow/rain/' forests.txt

 

Hloov cov ntaub ntawv thiab cov permissions

chmod {options} {permissions} {filename}

 

Sau tsis ntev los no commands siv

history

 

Yeej teem lub sij hawm kev pab raws qib

cron
crontab

 

Hloov cov ntaub ntawv tso cai

chmod {permission number} {some file or directory}
chmod 777 /storage

 

Hloov recursive ntaub ntawv tso cai

chmod -R {permission number} {some file or directory}

 

 

Sau ntawv cia Ncua