您的位置:首页 > 运维架构 > Linux

The Linux Command Line

2017-06-26 22:18 330 查看

Part 1 - Learning The Shell

1 - What Is The Shell

date  --  cal

df  --  to see the current amount of free space on your disk driver

free  --  to display the amount of free momery


2 - Navigation

pwd
cd  --  relative path
cd ~[user_name]  --  home directory


3 - Exploring The System

ls ~ /usr  --  multiple directories
ls -l  --  long format
ls -lt  -- sort by the file's modification time


OptionDescription
-FAppend a “/” if the name is a directory.
-SSort results by file size.
-tSort by modification time.
-rReverse.
drwxr-x---   4 sty   staff    136  6  3 10:11 .android
1-3-3-3  --  access rights to the file
1  --  indicates the type of file, "/" means a regular file, "d" indicates a directory
3  --  access rights for the file's owner
3  --  for the file's group
3  --  for everyone else


file filename  --  determining a file's type

macbook:EBooks sty$ file TLCL-16.07.pdf
TLCL-16.07.pdf: PDF document, version 1.4


less  --  view file contents
less is more


DirectoryComments
/The root directory. Where everything begins.
/binContains binaries programs that must be present for the system to boot and run.
/bootContains the Linux kernel, initial RAM disk image, and the boot loader.
/dev“Everything is a file”.
/etcContains all of the system-wide configuration files.
/optUsed to install “optional” software. Mainly used to hold commercial software products.
/usrContains all the programs and support files used by regular users.
/usr/binContains the executable programs installed by your linux distribution.
/usr/libThe shared libraries for the programs in /usr/bin.
/usr/localWhere programs that are not included with your distribution but are intended for system-wide use are installed.
/usr/sbinContains more system administration programs.
/usr/shareContains all the shared data by programs in /usr/bin. Includes things like default configuration files, icons, screen backgrounds, sound files, etc.

4 - Manipulating Files And Directories

cp
mv
mkdir
rm
ln  -- create hard and symbolic links


wildcards

WildcardsMatches
Data???Any file beginning with Data followed by exactly three characters
[abc]*Any file beginning with either an “a”, “b”, or “c”
Backup.[0-9]Any file beginning with Backup followed by one number
[[:upper:]]*Beginning with an uppercase letter
[![:digit:]]*Not beginning with a numera
*[[:lower:]123]Ending with a lowercase letter or the numerals 1, 2, or 3

mkdir

mkdir dir1 dir2 dir3


cp

cp item... directory. -- to copy multiple items


CommandResults
cp file1 file2If file2 exists, it is overwritten with the contents of file1, if not, create file2.
cp -i file1 file2Same as above, except that if file2 exists, the user is prompted before it is overwritten.
cp file1 file2 dir1Copy file1 and fie2 into directory dir1.
cp dir1/* dir2Using a wildcard, all the files in dir1 are copied into dir2.
cp -r dir1 dir2After the copy, dir2 will contain the same contents as directory dir1.

mv

mv item1 item2  --  to move or rename file or directory item1 to item2
mv item... directory  --  move one or more items from one directory to another


rm

CommandResults
rm file1Delete file1 silently.
rm -i file1Prompt while deleting.
rm -r file1 dir1Delete file1 and dir1 and its contents.
rm -rf file1 file2^_^

ln — create links

ln file link  --  hard link
ln -s item link  --  symbolic link where item is either a file or a directory


To be continue

To To To.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: