Linux Commands Cheat Sheet (AI Generated
)¶
User Management¶
Adding a User to the Sudo Group
Replaceusername with the actual username you want to add to the sudo group.
Creating a New User
Replaceusername with the actual username you want to create.
Deleting a User
Replaceusername with the actual username you want to delete.
Changing a User's Password
Replaceusername with the actual username whose password you want to change.
File and Directory Management¶
Creating a New Directory
Replacedirectory_name with the actual name of the directory you want to create.
Deleting a Directory
Replacedirectory_name with the actual name of the directory you want to delete.
Copying a File
Replacesource_file with the actual name of the file you want to copy, and destination_file with the actual name of the file you want to create.
Moving a File
Replacesource_file with the actual name of the file you want to move, and destination_file with the actual name of the file you want to create.
Changing File Permissions
Replacepermissions with the actual permissions you want to set (e.g., 755), and file_name with the actual name of the file whose permissions you want to change.
Changing File Ownership
Replaceuser with the actual username you want to set as the owner, group with the actual group name you want to set as the group, and file_name with the actual name of the file whose ownership you want to change.
Group Management¶
Adding a User to a Group
Replacegroup_name with the actual name of the group you want to add the user to, and username with the actual username you want to add.
Creating a New Group
Replacegroup_name with the actual name of the group you want to create.
Deleting a Group
Replacegroup_name with the actual name of the group you want to delete.
Adding a Folder to a Group
Replacegroup_name with the actual name of the group you want to add the folder to, and folder_name with the actual name of the folder you want to add.
System Information¶
Displaying System Information
Displays information about the system, including the kernel version, hostname, and architecture.Displaying CPU Information
Displays information about the CPU, including the number of cores, threads, and architecture.Displaying Memory Information
Displays information about the system's memory, including the total amount of memory, used memory, and free memory.Displaying Disk Information
Displays information about the system's disks, including the total size, used space, and available space.Networking¶
Displaying Network Interfaces
Displays information about the system's network interfaces, including the IP address, subnet mask, and gateway.Displaying Network Routes
Displays information about the system's network routes, including the destination IP address, gateway IP address, and interface.Displaying Network Statistics
Displays statistics about the system's network activity, including the number of packets sent and received, errors, and dropped packets.Security¶
Updating the System
Updates the system's package list and upgrades all installed packages to the latest version.Installing a Firewall
Installs the Uncomplicated Firewall (UFW) package, which provides a simple way to configure the system's firewall.Enabling the Firewall
Enables the UFW firewall, which will block all incoming traffic by default.Allowing Incoming Traffic on a Specific Port
Allows incoming traffic on a specific port number, replacing `Allowing Incoming Traffic on a Specific Port
Allows incoming traffic on a specific port number, replacingport_number with the actual port number you want to allow (e.g., 22 for SSH).
Blocking Incoming Traffic on a Specific Port
Blocks incoming traffic on a specific port number, replacingport_number with the actual port number you want to block.
Checking the Firewall Status
Displays the current status of the UFW firewall, including the list of allowed and blocked ports.Process Management¶
Killing a Process
Kills a process with the specifiedprocess_id.
Killing a Process by Name
Kills a process with the specifiedprocess_name.
Checking Running Processes
Displays a list of all running processes, including their process IDs, user IDs, and command lines.Checking System Resource Usage
Displays a real-time view of system resource usage, including CPU usage, memory usage, and disk usage.File System Management Creating a New File System
Creates a new file system on a device, replacingfile_system_type with the type of file system you want to create (e.g., ext4), and device_name with the name of the device you want to create the file system on.
Mounting a File System
Mounts a file system on a device, replacingdevice_name with the name of the device you want to mount, and mount_point with the directory where you want to mount the file system.
Unmounting a File System
Unmounts a file system from a device, replacingdevice_name with the name of the device you want to unmount.
Checking Disk Usage
Displays a list of all mounted file systems, including their disk usage and available space.Network File System (NFS) Management¶
Mounting an NFS Share
Mounts an NFS share from a server, replacingserver_name with the name of the server, share_name with the name of the share, and mount_point with the directory where you want to mount the share.
Unmounting an NFS Share
Unmounts an NFS share from a mount point, replacingmount_point with the directory where the share is mounted.
Checking NFS Shares
Displays a list of all NFS shares exported by a server, replacingserver_name with the name of the server.
Conclusion¶
This cheat sheet provides a comprehensive list of Linux commands for various tasks, including user management, file and directory management, system information, networking, security, process management, file system management, and NFS management. These commands can help you perform common tasks and troubleshoot issues in a Linux environment.