Understanding Linux File and Directory Properties

Linux file or directory properties:

Run the below given command:

touch test.txt

mkdir directory

On running ls -l we get the following output:

drwxr-xr-x 2 user user 2 May 28 11:03 directory
-rw-r--r-- 1 user user 0 May 28 11:03 test.txt

Type        # of links   Owner   Group   Size   Month   Day    Time     Name
drwxr-xr-x      2        user    user     2      May    28     11:03   directory
-rw-r--r--      1        user    user     0      May    28     11:03   test.txt

Meaning of all the column heading:

Type -> d stands for directory and blank space for file in the first column
# of links -> The second column is the number of hard links to the file. For a directory, the number of hard links is the number of immediate subdirectories it has plus its parent directory and itself.
Owner -> default user who created the file or directory.
Group -> default Group who created the file or directory.
Size -> Size of file or directory.
Month -> Month when file or directory got created.
Day -> Day when file or directory got created.
Time -> Time when file or directory got created.
Name -> Name of file or directory.

Linux file types:

File SymbolMeaning
Regular file
dDirectory
lLink
cSpecial or device file
ssocket
pNamed Pipe
bblocked Pipe

What is root in Linux?

There are three types of root on Linux System:-

Root Account -> A root account, also known as a superuser account, is a special user account in computing systems that provides the highest level of access to the system. The root account is typically used for administrative purposes, such as logging in, creating secondary users, and more.

Root as / -> The root directory is the top-level directory in a computer’s file system, and is often represented by a forward slash (“/”) on Unix-like operating systems (including Linux and macOS) or a backslash (“\”) on Windows systems.

Root home directory -> The root directory is the top-level directory in a folder structure, and all other folders branch out from it. In Linux, the root directory is referred to as /, and the home directory for the root user is /root/. The home directories for regular users are contained in /home/.

Changing password:

You can change the password of a Linux user by running passwd <username> on Linux shell.

File System Paths:

There are two paths to navigate to file system:
1. Absolute Path
2. Relative path

Absolute path :- Absolute path always begin with “/”. This indicates that the path starts at the root directory.

Ex: cd /var/log/test

Relative path :- Relative path doesn’t begin with “/”. It identifies a location relative to your current position.

Ex: cd /var
cd log
cd test

Creating files and directories:

Creating files:

touch <file_name>
vi <file_name>

Creating directories:

mkdir <dir_name>

Copy directories:

Command to copy a directory:

cp -R <source_dir> <destination_dir>

Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here