inode = index node. A data structure describes a file or a directory. For a user, a file is a path like
/home/yourname/whatever.txt; for the operating system, an
inode is used to store the extra info about the file, like file type, owner, group, who can access the file, size of the file, last modified time, etc.
$ touch a.txt # Create an empty file $ echo "hello" > b.txt # Create a file with "hello" $ echo "world" >> b.txt # append content to the existing file
$ rm a.txt
$ mkdir dir1 $ rmdir dir1 $ rm -r dir2
ln -s will create symbolic links, or soft links, or symlinks(calling
symlink system call), while without
-s will create hard links(calling
link system call).
$ sudo ln -s <source_path> <target_path>
$ ln -s 0.1.0-SNAPSHOT/ snapshot $ ls -l ... snapshot -> 0.1.0-SNAPSHOT/
ls -l to check file info:
$ ls -l -rw-rw-rw- 1 ubuntu ubuntu 13 Mar 12 16:56 a.txt
The first char is the type of the file:
-: regular file
l: symbolic link
Next are 3 groups of
rwx describing the permissions:
rwx: permissions for owner of the file
rwx: permissions for group owners of the file
rwx: permissions for all other users
r: permission to read
w: permission to write
x: permission to execute
-: no permission
rwx, we can also use a number between 0 and 7 to describe the permissions: map
rwx to the binary form of the number, for example,
rwx: you have all the permissions
rw-: you can read or write but not execute
r-x: you can read or execute but not edit
r--: read only
---: no permission at all
Then a file's permission can be described by 3 numbers, e.g.
755 is equivalent to
To change a file's permission, use
$ chmod 755 a.txt
or use something like this if you do not like the numbers:
$ chmod a+rw a.txt
a is for all users,
+ is to add permissions,
rw is for read and write. Check
$ man chmod for all available options.
-rw-rw-rw- 1 ubuntu ubuntu 13 Mar 12 16:56 a.txt ------ ------ | | | |---- group owner of the file |----------- owner of the file
To change owners, use
$ sudo chown root:root a.txt
root is the OWNER while the second
root is the GROUP.
Find files with
.txt suffix in home directory
$ find ~ -name "*.txt"
$ locate passwd
locate uses a database (using
updatedb) rather than hunting individual directory paths.
which is used for locating binaries;
whereis lists locations for binaries, sources, and man pages.
grep is used to search inside the content.