Linux: Basic Command Introduction
1. File Name convention:
1) All characters except '/' are regarded as legal as '/' is used for file path delimeter.
2) Space, Tab, Backspace, @, #, $, &, (, ) and - are not recommanded to be used as file name.
3) Do not use '.' as the first character of file name. Because file name starts with '.' is regarded as hidden file.
4) File name is case sensitive. Linux is case sensitive.
2. Basic comman format:
1) Command -Options Params
Eg: ls -al /etc
1) When we have multiple options, we can put them together.
2) . represents current folder and .. represents parent folder.
2) Command can be categorized into two kinds:
1) root command
usually stored in /sbin or /usr/sbin folder with the format of binary file.
2) user command
usually stored in /bin or /usr/bin folder with the format of binary file.
3. Command Intro:
1) Command Name: ls
Command Derived From: list
Command Path: /bin/ls
Command Permission: all users
Command Description: show all the dirs and files in current path
Command Syntax: ls [-ald] [file or dir]
a: Show all files including hidden files.
l: Show detail information
d: Show current folder properties
Result Sample:
drwxrwxr-x 6 administrator administrator 4096 Aug 17 23:25 apache-maven-3.1.0
-rw-rw-r-- 1 administrator administrator 5439122 Aug 17 23:24 apache-maven-3.1.0-bin.tar.gz
Explaination:
1) The first letter: Means the file format.
'd' means Directory.
'-' means Binary file.
'l' means soft link file.
2) The following 9 letters: Means the authority of three kind of user.
File owner(u) -> The user that created the file/folder. And it can also be transfered to another person.
User group(g) -> The user group that has the right of controlling this file.
Others(o) -> ...
3) The digit 6 or 1 means the hard link count. Will explain later.
4) The following 'administrator' means the owner of this file.
5) The following 'administrator' means the belonged group of this file.
6) The following '4096' and '5439122' means the size of this file/folder. But this is not accurate when applied with folder size.
7) The timestamp means the file creation date or last modified date.
2) Command Name: cd
Command Derived From: change directory
Command Path: shell imbeded command
Command Permission: all users
Command Description: change current directory
Command Syntax: cd [path]
Example:
cd / change to root folder
cd .. change to parent folder
3) Command Name: pwd
Command Derived From: print working directory
Command Path: /bin/pwd
Command Permission: all users
Command Description: show current direcory
Command Syntax: pwd
4) Command Name: mkdir
Command Derived From: make directories
Command Path: /bin/mkdir
Command Permission: all users
Command Description: create new directory/folder
Command Syntax: mkdir [dir name]
Example:
mkdir /test -> Make directory under the context of root folder.
mkdir test -> Make directory under the context of current working directory.
5) Command Name: touch
Command Path: /bin/touch
Command Permission: all users
Command Description: create a new blank file
Command Syntax: touch [file name]
Example:
touch newfile
6) Command Name: cp
Command Derived From: copy
Command Path: /bin/cp
Command Permission: all users
Command Description: copy file or folder
Command Syntax: cp -R [source folder name] [dest folder name]
[source file name] [source file name] ... [dest folder name] [dest folder name] ...
Example:
cp Test.java ..
cp Test1.java Test2.java Test3.java ..