Code 的[]代表需要打的參數, 檔案或資料夾,實際[]的框框不需要打。

展示硬體內容


inxi -Fxz


kill application

這裏PID是每個application的id號碼
pseudo code:
 kill [PID]  
在command line 打上 top就可以查看所有application的PID
force:
 kill -9 [PID] 
關掉所有相關名字的application, ex. 關掉firefox
 killall firefox  

// list kill signal
kill -l

解壓縮參考

凍仁的筆記 compress a directory:
tar -czfv compressName.tar.gz directoryName // The c option stands for create. // The z option stands for .gz // The f option is used to write to file the archive. // The v option display compress information.

list "*.tar.gz" contains.
tar -tvf compressName.tar.gz compress files and directory into *.gz
// easy way to compress files
gzip -k file1 file2
// result
// file1.gz and file2.gz

// standard way 
gzip -c fileName > compressName.gz

// compress all the files in directory
gzip -r directoryName

// show information 
gzip -v fileName

// decompress
gzip -d fileName.gz
// equal to "gzip -d ..."
gunzip fileName.gz

// archive
tar -cf archive.tar file1 file2

// The c option stands for create, the f option is used to write to file the archive.


// To extract files from an archive in the current folder:
tar -xf archive.tar

// The x option stands for extract.

// To extract them to a specify directory.
tar -xf archive.tar -C directory

whoami

Show user name currently logged into the terminal session.

command:

whoami

man

Help you understand all the other commands.

command:

man [command]

clear

clear
I prefer to use the "Control+l".
Because using "clear" will put all commands that you have used into history.
The "Control+l" is just scrolling down until your position.

mkdir

Create multiple folders. mkdir [folderName1] [folderName2]
Create nested folders.
mkdir -p [folderName]

// example
mkdir -p mainFolder/subFolder/subsubFolder


rm

Using carefully! It will delete files permanently.
delete file/directory.
//delete file
rm [fileName]

// verbose
rm -v [fileName]

// delete directory
rm -r [directoryName]


mv

move or rename
// move files
mv [file1] [file2] [file3] [directory/]

// move directory
mv [directoryName/] [./position/]

// rename file
mv [oldName] [newName]

// rename directory
mv [oldDirectoryName/] [newDirectoryName]

cp

copy file or directory
// copy file and rename
cp [sourceFile] [destination]

// copy directory recursively
cp -r [sourceDirectory] [distination]


head

output the first part of files
head [OPTION]... [FILE]...

tail

output the last part of files
tail [OPTION]... [FILE]...

// without end file
// If you want to read file contains refreshly.
tail fileName -f

redirecting standard output

// write into file
>

// append
>>


// example
ls > list.txt

// example
ls >> list_append.txt

cat

contatenate files and print on the standard output.
cat [OPTION]... [FILE]...

less

read files contain
less fileName
"/findStr"

wc

print new linem, and byte counts for each file.

piping

Counting result from command "ls -la".
ls -la | wc
Counting result from command "cat fileName.txt".
cat fileName.txt | wc -l

sort

sort file contains.

uniq

// display duplicate one
uniq -d

// display single one
uniq -u

// piping "sort"
sort flavors.txt | uniq -u

// counting and sort
sort flavors.txt | uniq -c | sort -nr

?

any single character
// example: remove all extension with two characters
rm *.??

dot dot

arithmetic series
// create Day1~Day100 file name
touch Day{1..100}.txt

diff

Display different between two files contains.
diff [FILE1] [FILE2]

find

find file with name, size, type...
//find recursively with name
find . -name 'fileName'

// find directory with name
find . -type d -name 'directoryName'

// multiple files
find . -type f -name 'name1' -or -name 'name2'

// search with size
find -type f -size +100k

//search modify time
// last 24 hours
find . -type f -mtime -1
// more than 3 days age
find . -type f -mtime +3

// search result and execute commands
// find files and catenation
find .-type f -size -exec cat {} \;

grep

find string in files
// find string in file
grep string fileName.txt
 // recursively find string in folder "path"
grep -r str /path/
參數:
-w: 只顯示搜尋到的內容
-i: 不分大小寫
-n: 顯示行數

du

estimate file space usage
// display readable and sort them.
du -h | sort 

df

report file system disk space usage.
// human readable
df -h

history

//show ID and less them
history | less
// example
...
539  du -h
// using ID command 539 means 'du -h'
!539

ps

report a snapshot of the current processes.
ps [OPTIONS]
// pipeline process and name
ps axww | grep "Visual"

top

display Linux processes
// for mem
top -o mem

jobs

display Stopped processes
jobs

If you want to rerun processes.

foreground

fg ID

background

bg ID

sleep

delay with seconds
// sleep in background
sleep 10 &

alias

The alias is working until terminating it.
If you want to work it in all time.
Type in ~/.bashrc
// double quotes
// The variable will be assign to now value. Whatwhere you use it, it cannot change its value.
alias ll="ls $PWD"

// single quote
// The variable would be changed when you use it. 
alias ll='ls $PWD'
// modify on startup // edit ~/.bashrc // or edit ~/.bashrc_aliases // type your alias command in the context. // input source ~/.bashrc or source ~/.bashrc_aliases

Display variable

printenv

xargs

build and execute command lines from standard input.
// example
// It will get arguments from deadPlayer.txt and put into rm.
cat deadPlayer.txt | xargs rm

// another example
find . -size +10M | xargs ls -lh

ln

make links between files/Directories
// hard link
ln source.txt target.txt

// soft link
// It can link directory.
ln -s source.txt target.txt
ln -s sourceDir/ targetDir/

who

show who is logged on

su

run a command with substitute user and group ID.
su [USERNAME]

dpkg

install .deb 小坦克 - dpkg命令的用法

passwd

change password

chown

change file owner and group
chown [OWNER] [FILE]

// recursively
chown -R owner fileName
鳥哥Linux





ncal

calendar

chmod

changing permissions


// Make an example:
// Changing others' permission to execute.
chmod o+x [FILENAME]

Battery Status

// standard command
acpi

setting scheduler

crontab -e
reference

player

In pi:
omxplayer


wget

download files in terminal.

reference

--limit-rate=432k

Checking usb or disk from other device

blkid
// or 
sudo fdisk -l
// or 
sudo parted -l

Checking main disk

// -h: Be readable for human
df -h

Open folder in command line

xdg-open ./folderName

Binary Application

bin path:
/usr/local/bin

pause script

// Same as "pause" in windows
read -r -p "Press any other key to continue..." key