Linux and other Unix-like Operating systems maintain consistency by treating everything as a file (even the hardware devices). The keyboard, mouse, printers, monitor, hard disk, processes, even the directories are treated as files in Linux. The regular files contain data such as text (text files), music, videos (multimedia files), etc.
Other than regular data, there are some other data about these files, such as their size, ownership, permissions, timestamp etc. This metadata about a file is managed with a data structure known as an inode (index node).
Every Linux file or directory (from a technical point of view, there’s no real difference between them) has an inode, and this inode contains all of the file’s metadata (ie all the administrative data needed to read a file is stored in its inode).
For example, the inode contains a list of all the blocks in which a file is stored, the owner information for that file, permissions and all other attributes that are set for the file.
Inode limits is per filesystem and is decided at filesystem creation time. The maximum directory size dependent on the filesystem and thus the exact limit differs.
For better performance make your directories smaller by sorting files into subdirectories rather having one large directory.
Inode number is also known as index number. An inode is a unique number assigned to files and directories while it is created. The inode number will be unique to entire filesystem.
An inode is a data structure on a traditional Unix-style file system such as ext3 or ext4 which stores the properties of a file and directories.
Linux extended filesystems such as ext3 or ext4 maintain an array of these inodes called the inode table. This table contains list of all files in that filesystem. The individual inodes in inode table have a unique number (unique to that filesystem) called the inode number.
File type: regular file, directory, pipe etc.
Permissions to that file: read, write, execute
Link count: The number of hard link relative to an inode
User ID: owner of file
Group ID: group owner
Size of file: or major/minor number in case of some special files
Time stamp: access time, modification time and (inode) change time
Attributes: immutable' for example
Access control list: permissions for special users/groups
Link to location of file
Other metadata about the file
Symbolic links (or soft links)
Hard links
To send a signal to a process, use the kill, pkill or pgrep commands we mentioned earlier on. But programs can only respond to signals if they are programmed to recognize those signals.
And most signals are for internal use by the system, or for programmers when they write code. The following are signals which are useful to a system user:
SIGHUP 1 – sent to a process when its controlling terminal is closed.
SIGINT 2 – sent to a process by its controlling terminal when a user interrupts the process by pressing [Ctrl+C].
SIGQUIT 3 – sent to a process if the user sends a quit signal [Ctrl+D].
SIGKILL 9 – this signal immediately terminates (kills) a process and the process will not perform any clean-up operations.
SIGTERM 15 – this a program termination signal (kill will send this by default).
SIGTSTP 20 – sent to a process by its controlling terminal to request it to stop (terminal stop); initiated by the user pressing [Ctrl+Z].
The nice and renice commands in Linux are used to control the scheduling priority of processes, which determines how much CPU time they receive compared to other processes.
nice command:
Used to start a new process with a specified "nice value," which adjusts its priority.
Syntax:
nice -n <nice_value> <command>
The nice value ranges from -20 (highest priority) to 19 (lowest priority). Lower (or negative) nice values mean higher priority, so the process gets more CPU time. Higher (positive) nice values lower the priority, so the process gets less CPU time.
Example:
nice -n 10 gnome-terminal
This starts gnome-terminal with a lower priority than default.
renice command:
Used to change the priority of an already running process.
Syntax:
renice -n <nice_value> -p <PID>
-n <nice_value>: The new nice value to assign.
-p <PID>: The process ID of the process to modify.
You can also use -g <group_id> to change all processes of a group, or -u <user_id> for all processes of a user.
Example:
renice -n 15 -p 77982
This changes the nice value of process 77982 to 15, lowering its priority.
Key points:
Default nice value is usually 0.
Regular users can only increase the nice value (lower priority) of their own processes, not decrease it (raise priority). Only the root user can set negative nice values or change the priority of other users' processes.
The NI column in the top command output shows the current nice value of each process.
These commands are essential for optimizing system performance, especially on multi-user or multi-process systems, by ensuring critical tasks get the CPU time they need while less important tasks yield resources.