"Everything is a file." This phrase means that everything in the linux system like files, directories, sockets, pipes, hardware, ...is represented by a file descriptor abstracted over the virtual filesystem layer in the kernel.
Files have 3 types: ordinary or plain files, directories, and special or device files.
To list the files in the "directory_path" directory, just type:
ls directory_path
The directory_path can be absolue path or relative path. The absoluste path start from root directory(e.g. /etc/httpd/conf) where relative path start from the current path(e.g. example/test). You can show your current path with this cmd: pwd. To list files in the current directory, you can just type this cmd: ls
List all files(including the hidding files whick start with "."): ls -a
use a long listing format: ls -l.
1. Create an empty file: touch file-name. The touch command is used to change a file's time stamp. so when you use touch with an exist file, it will change the file's last modified time to now.
2. Use "cat" command to create a file: cat >file-name. It will create a new file named file-name if the file doesn't exist(in written mode), or into overwritten mode when the file exist. After writing the text you need, press ctrl+d to save and exit from the writing mode. For more information about cat, check CAT.
3. use "vim" command. Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.It is included as "vi" with most UNIX systems and with Apple OS X. Take the following steps to simply create a file:
* type: vim file-name.
* press "i", "o", or "a", switch to insert mode, input the text you need.
* press "Esc", switch to command mode, then type ":wq" to save and quit the vim.
More information about vim, check VIM.
1. Remove a regular file: rm filename; To remove more than one file: rm filename1 filename2 filename3
2. Remove a directory: rm -r directory-name.
Copy a file: cp file-name destination-directory.
Move a file: mv file-name destination-directory.
Rename a file:
* Change to the directory where the file located: cd file-directory;
* mv file-name new-file-name.
The following command will list the file's attributes in long list format:
ls -l filename or ls -l to list all files in the current directory.
The first column is the file's permission, it includes 10 bits:
* the first one can be "-", "d", or "l" which indicate regular file, directory file, and link file respectively;
* the value of 2 to 4 bits indicate the owner's read, write, and execute permission respectively;
* the value of 5 to 7 bits indicate the group's read, write,and execute permission respectively;
* the value of 8 to 10 bits indicate the others' read, write, and execute permission respectively.
For example, the file's owner have read, write, execute permission, the value of the 2 to 4 bits will be "rwx", and if the group user only have the read permission, the value of the 5 to 7 bits will be "r--".
To modify a file's permission, use the chmod command. chmod changes the file mode bits of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.
* symbolic mode: [ugoa...][[-+=][perms...]...]. perms is either zero or more letters from the set rwxXst, or a single letter from the set ugo. Multiple symbolic modes can be given, separated by commas. u g o means the owner, the group user, and the others respectively, and the a means all include u g o. - means "remove perms(rwxXst)", + means "add perms(rwxXst)", = means "add them and remove unmentioned bits(but the directory's unmentioned set user and group ID bits are not affected.)".