File System and Administration Commands
Unix
File System and Administration Commands:
du → gives you disk usage size, default it shows in Kb, du -m displays in Mb
df → gives available free space and file system disk usage
free → Display amount of free and used memory in the system
chown : To change ownership of a file, chown' performs the same function as 'chgrp
chown user1 sample.txt → change the owner of file
chown :mygroup file.txt → change group of file
Change both the owner and group of file in a single command.
chown user1:mygroup file.txt
chgrp - To change group ownership
chgrp oracleadmin/user/database
passwd - change user password
Example-1:
Change your own password:
$ passwd
Output:
$ passwd
Changing password for ubuntu.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Example-2:
Change the password for the user named username:
$ sudo passwd username
Output:
$ sudo passwd user1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
ls -i → every file/directory have unique id’s nothing but INODE values
ls -i gives a list of files/directories along with inode values
ln → used to link files. Ln has 2 types. 1) soft link 2) Hard Link. By default, it creates a hard link. The destination file should not exist in order to create a link
Hard Link : ln file1 file2
It has the same INODE value
If we delete the source file. It doesn't affect the destination file(destination file does not delete)
SOFT LINK : ln -s file1 file2
It has a different INODE value
If we delete the source file. It affects the destination file(destination file deleted) but the link remains the same(it means whenever the source file created destination file created)
chmod - used to change permissions of files. File permissions are 2 types they are symbolic and octal
symbolic :
U - indicates the owner
G - indicates the group
O - indicates other
+ → Adding permissions
Display permissions on following order, First → owner, second → group, third → others
→ Performance-wise Ocotal is the better one
→ Adding and removing permissions, symbolic is better one because we add or remove permissions to a specific one(either owner, group, or user) but whereas octal entire file permissions need to specify
chmod g+w file2 → adding write permissions to the group for file2
chmod u+r file2 → adding read permissions to the owner for file2
chmod g-r file2 → removing read permissions to the group for file2
chmod o+w file2 → adding write permissions to other for file2
chmod o-rw file2 → removing read, write permissions to other for file2
chmod o+rwx file2 → adding read, write and execute permissions to other for file2
Octal :
Order of permissions
First - owner
Second - group
Third - Other
4 - Read permission
2- Write Permission
1- Execute Permission
0 - No permission
chmod 421 → adding read permission to owner; write to group ; execute to other
chmod 621 → adding read&write permission to owner; write to group; execute to other
chmod 671 → adding read&write permission to owner; read,write and execute to group ; execute to other
chmod 700 → read, write and execute permission to owner;
Comments
Post a Comment