
Directory Operations
Managing directories is as crucial as managing files in a Linux system. Here are some commands specifically used for directory operations:
mkdir directoryname
: This command creates a new directory with the namedirectoryname
in the current working directory.rmdir directoryname
: Deletes the directory nameddirectoryname
. The directory must be empty for the command to succeed.cp -r source destination
: Copies the source directory to the destination directory recursively, including all its files and sub-directories.mv olddir newdir
: Renames the directoryolddir
tonewdir
. This command can also be used to move directories.find / -type d -name directoryname
: Searches for directories with the namedirectoryname
starting from the root directory. The-type d
option restricts the search to directories only.
Process Operations
Processes are instances of running programs. Linux provides several commands to manage processes:
ps
: Shows the currently active processes for the current shell.top
: Provides a dynamic, real-time view of all running processes, including system performance metrics.kill pid
: Sends a signal to the process with the specified process ID (pid) to terminate it.pkill name
: Terminates processes based on name. This is useful when you don’t know the pid.bg
: Resumes a suspended job in the background, allowing it to continue running without tying up the terminal.fg
: Brings the most recent background job to the foreground.fg n
: Brings the job specified by its job numbern
to the foreground.renice +n [pid]
: Changes the scheduling priority of a process. The+n
adjusts the niceness, which affects process scheduling.&>filename
: Redirects both standard output (stdout) and standard error (stderr) to the filefilename
.1>filename
: Redirects stdout to the filefilename
.2>filename
: Redirects stderr to the filefilename
.
File Permissions
File permissions are a fundamental aspect of Linux security and user management:
chmod octal filename
: Changes the permissions of a file tooctal
, whereoctal
is a three-digit number representing the read, write, and execute permissions for the owner, group, and others.chown ownername filename
: Changes the owner of the file toownername
.chgrp groupname filename
: Changes the group ownership of the file togroupname
.
These commands allow users to create and manage directories, control and prioritize system processes, and secure files with appropriate permissions. Mastery of these commands is essential for system administration and maintaining an organized and secure Linux environment.