1) Command Name: cat
Command Derived From: concatenate and display files
Command Path: /bin/cat
Command Auth: all users
Command Function: display the content of the file
Command Syntax: cat [file name]
Example:
cat epl-v10.html -> If the file is too long, then there may be overflow in current display window.
2) Command Name: more
Command Derived From: more
Command Path: /bin/more
Command Auth: all users
Command Function: display all the content of the file by paging
Command Syntax: more [file name]
(Space) or f -> show next page
(Enter) -> show next line
(q) or (Q) -> quit
Example:
more epl-v10.html -> If the file is too long, then there may be paging in current display window.
-> Then we should use (Space or f) and (Enter) and (Q or q) to browse all the content.
3) Command Name: head
Command Derived From: head
Command Path: /bin/head
Command Auth: all users
Command Function: display the specific lines from the head for the content of the file
Command Syntax: head -XX [file name]
-XX means the number of lines. If we didn't specific the count, then it is 10 by defalut.
Example:
head -100 epl-v10.html -> Only display the first 100 lines for the file.
4) Command Name: tail
Command Derived From: tail
Command Path: /bin/tail
Command Auth: all users
Command Function: display the specific lines from the tail for the content of the file
Command Syntax: head -XX [file name]
-f [file name]
-XX means the number of lines. If we didn't specific the count, then it is 10 by defalut.
-f means the dynamic display of file content. Is very useful for inspecting running log
Example:
tail -100 epl-v10.html -> Only display the last 100 lines for the file.
tail -f log.log -> As long as the file is updated, the display.
5) Command Name: ln
Command Derived From: link
Command Path: /bin/ln
Command Auth: all users
Command Function: create link file for a specific file
Command Syntax: ln -s [source file] [dest file]
-s create soft link
Example:
ln -s /etc/issue /etc/issue.soft -> Create soft link for file etc/issue
ln /etc/issue /etc/issue.hard -> Create hard link for file etc/issue
Explanation:
1) Soft link:
administrator@ubuntu:~/Downloads/eclipse/configuration$ ls -l config.ini.soft config.ini
-rw-rw-r-- 1 administrator administrator 862 Jun 14 10:52 config.ini
lrwxrwxrwx 1 administrator administrator 10 Sep 18 08:04 config.ini.soft -> config.ini
We can find out the difference between soft link file and normal file.
1) The auth of soft link file is 'rwx' for all user.
But it doesn't matter as when we click soft link, we are nevagated into the source.
So we don't care the auth of soft link file.
2) The timestamp for soft link file.
It is the time that this soft link file is created and not the time that the source file is created.
3) Soft link is just like 'shortcut' in Windows.
2) Hard link:
administrator@ubuntu:~/Downloads/eclipse/configuration$ ls -l config.ini config.ini.hard
-rw-rw-r-- 2 administrator administrator 862 Jun 14 10:52 config.ini
-rw-rw-r-- 2 administrator administrator 862 Jun 14 10:52 config.ini.hard
We can find out that the two files are exactly the same.
It is just like copy config.ini.
1) But we should pay attention that the two files are synchronous.
That means whatever we did to one file, this modification will reflect on the other file.
2) Also, if we "cp config.ini config.ini.hard" then the time stamp for config.ini.hard would be different
from config.ini.
if we "cp -p config.ini config.ini.hard" then the time stamp for config.ini.har would be the same with
config.ini.
3) Difference beteween soft link & hard link:
1) If we rm sourcefile, we cannot visit soft link file any more. But we can visit hard link file.
2) But why hard link file can be synchronous with source file?
Linux kernel cannot recognize object that is not digit. So any object that would be handled by kernel should
have a digit representation. For file, that digit is inode. For user, that digit is uid. For usergroup, that digit is gid.
For process, that digit is pid. Kernel cannot recoginze/handle object that doesn't have a digit representation.
administrator@ubuntu:~/Test3$ ls -i
531462 hello.hard 531462 hello.ini 531463 hello.soft
We can find out that the inode for hard link file and source file is the same.
This single inode will reflect into two files hello.hard and hello.ini.
When we rm hello.ini or hello.hard, we only cut a branch of this reflection and will not affect the other branch.
3) Hard link file cannot be generated across the file system.
6) Command Name: chmod
Command Derived From: change the permissions mode of a file
Command Path: /bin/chmod
Command Auth: all users
Command Function: change the permissions of file or dir
Command Syntax: chmod [{ugo}{+-=}{rwx}] [file name or folder name]
[mode=421] [file name or folder name]
Example:
chmod u+x hello.ini -> Add x permission to the file owner.
administrator@ubuntu:~/Test3$ ls -l hello.ini
-rwxrw-r-- 1 administrator administrator 27 Sep 18 08:27 hello.ini
chmod g+x hello.ini
administrator@ubuntu:~/Test3$ ls -l hello.ini
-rwxrwxr-- 1 administrator administrator 27 Sep 18 08:27 hello.ini
chmod g-x hello.ini
administrator@ubuntu:~/Test3$ ls -l hello.ini
-rwxrw-r-- 1 administrator administrator 27 Sep 18 08:27 hello.ini
u - means the owner
g - means group that it belongs to
o - means others
Example2:
r = 4 w = 2 x = 1
rwxr-xr-- represents: 754
rw-r-x--x represents: 651
This kind of representation is very important cause it is commonly used in shell script.
administrator@ubuntu:~/Test3$ chmod 766 hello.ini
administrator@ubuntu:~/Test3$ ls -l hello.ini
-rwxrw-rw- 1 administrator administrator 27 Sep 18 08:27 hello.ini
administrator@ubuntu:~/Test3$ mkdir pre
administrator@ubuntu:~/Test3$ ls -ld pre/
drwxrwxr-x 2 administrator administrator 4096 Sep 19 11:03 pre/
administrator@ubuntu:~/Test3$ touch pre/test.java
administrator@ubuntu:~/Test3$ ls -l pre/test.java
-rw-rw-r-- 1 administrator administrator 0 Sep 19 11:05 pre/test.java
administrator@ubuntu:~/Test3$ chmod 777 pre/test.java
administrator@ubuntu:~/Test3$ ls -l pre/test.java
-rwxrwxrwx 1 administrator administrator 0 Sep 19 11:05 pre/test.java
administrator@ubuntu:~/Test3$ chmod 754 pre/
administrator@ubuntu:~/Test3$ ls -ld pre/
drwxr-xr-- 2 administrator administrator 4096 Sep 19 11:05 pre/
Q: Can other user(o) delete this pre/test.java?
To be examined. --> Other user cannot delete pre/test.java!
administrator@ubuntu:~/Test3$ ls -ld pre
drwxr-xr-x 2 administrator administrator 4096 Sep 19 11:05 pre
administrator@ubuntu:~/Test3$ ls -l pre/test.java
-rwxrwxrwx 1 administrator administrator 0 Sep 19 11:05 pre/test.java
administrator@ubuntu:~/Test3$ chmod 777 pre/
administrator@ubuntu:~/Test3$ chmod 644 pre/test.java
administrator@ubuntu:~/Test3$ ls -ld pre
drwxrwxrwx 2 administrator administrator 4096 Sep 19 11:05 pre
administrator@ubuntu:~/Test3$ ls -l pre/test.java
-rw-r--r-- 1 administrator administrator 0 Sep 19 11:05 pre/test.java
Q: Can other user(o) delete this pre/test.java?
To be examined. --> Other user can delete pre/test.java!
WHY?
We need a better understanding of permission in Linux.
We should pay attention that rwx means different for file and folder.
For file:
r----cat, more, head, tail
w---vi, gedit, echo
x---command, script...
For folder:
r----ls
w--touch, mkdir, rm
x---cd
As convention, r and x are tightly bind when it comes to the permission of a folder.
If we can ls this folder, then we should be able to cd into this folder.
If we can cd into this folder, but we cannot ls this folder, that would be jokey.
7) Command Name: chown
Command Derived From: change file ownership
Command Path: /bin/chown
Command Auth: all users
Command Function: change file or dir's owner
Command Syntax: chown [username] [filename]
Example:
chown administrator test.java ->Change the owner of file test.java to administrator
Q: Who can execute chown for a specific file or folder?
A:
相关推荐
The basic Linux commands you'll use most often. Creating, renaming, moving, and deleting directories. Listing, reading, creating, editing, copying, and deleting files. Exactly how permissions work ...
### Linux for ... this book provides a comprehensive introduction to Linux programming, covering a wide range of topics from command line basics to advanced scripting and programming techniques.
Basic Structure of Traffic Control in Linux 367 Section 18.3. Traffic Control in the Outgoing Direction 367 Section 18.4. Kernel Structures and Interfaces 369 Section 18.5. Ingress Policing 378...
Basic Structure of Traffic Control in Linux 367 Section 18.3. Traffic Control in the Outgoing Direction 367 Section 18.4. Kernel Structures and Interfaces 369 Section 18.5. Ingress Policing ...
ii Table of Contents Slicing file names based on extension 84 Renaming and moving files in bulk 86 Spell checking and dictionary manipulation 89 Automating interactive input 90 Chapter 3: File In, ...
- **Understanding the Command Line**: Basic concepts and terminologies used in the shell environment. - **Navigating Directories**: Moving around the file system using commands like `cd`, `ls`, and `...
#### Introduction The Linux System Administrator’s Guide Version 0.9 is a comprehensive resource aimed at helping new and experienced system administrators understand the nuances of managing Linux ...
- **Scripting Basics**: Introduction to basic scripting concepts and examples of simple scripts are included. **Software Management** - **Package Management**: The book covers package management ...
**1.1 引言 (Chapter 1: Introduction)** - **目标**: 介绍Unix的基本概念和发展历史。 - **内容**: 解释Unix的基本特性和优势,包括其对开发者友好性、稳定性和可移植性。 **1.2 获取帮助 (Chapter 2: Getting ...
A Detailed Introduction to I/O and I/O Redirection F. Standard Command-Line Options G. Important Files H. Important System Directories I. Localization J. History Commands K. A Sample .bashrc File L. ...
#### Introduction Apache Geronimo is a robust and flexible open-source Java EE (previously known as J2EE) application server. The "geronimo-book.pdf" provides detailed guidance on installing, ...
- **Introduction**(介绍):Apache HBase 是一个分布式的、可扩展的大数据存储系统,基于Google的Bigtable论文实现。它提供了高可靠性、高性能、面向列的数据存储能力。适合于存储海量半结构化/非结构化数据。 - ...
#### Introduction to Apache Impala (Incubating) Apache Impala is a high-performance, distributed SQL query engine that enables fast, interactive SQL queries on data stored in Apache Hadoop's HDFS, ...
PEP 389: The argparse Module for Parsing Command Lines PEP 391: Dictionary-Based Configuration For Logging PEP 3106: Dictionary Views PEP 3137: The memoryview Object Other Language Changes ...
- **Usage in Console Applications**: Python for Delphi can be used in console applications, making it suitable for command-line tools and scripts. - **Lazarus/FPC Support**: There is also support for ...
It would be useful to have some basic knowledge of Centos Linux and Scala. But don’t be deterred if you don’t; I believe that if you are interested in these topics and willing to learn, you will ...