Open afm719 opened 1 month ago
pwd
ls
ls -l
ls -a
.
cd
cd ..
cd ~
mkdir <directory_name>
rmdir <directory_name>
rm <file_name>
rm -r <directory_name>
touch <file_name>
cp <source> <destination>
cp -r <source_directory> <destination_directory>
mv <source> <destination>
cat <file_name>
less <file_name>
head <file_name>
tail <file_name>
tail -f <file_name>
df -h
du -h <directory_name>
top
htop
uname -a
free -h
lscpu
whoami
adduser <username>
deluser <username>
passwd <username>
su <username>
sudo <command>
sudo apt update
sudo apt upgrade
sudo apt install <package_name>
sudo apt remove <package_name>
sudo apt search <package_name>
sudo apt show <package_name>
ifconfig
ip
ip a
ping <hostname>
traceroute <hostname>
netstat -tuln
curl <url>
chmod <permissions> <file_name>
chmod 755 <file_name>
chown <user>:<group> <file_name>
find <directory> -name <file_name>
grep <pattern> <file_name>
locate <file_name>
mlocate
shutdown
shutdown -h now
reboot
systemctl <action> <service_name>
history
clear
echo <text>
man <command>
find <directory> -type f -name <file_name>
find <directory> -type d -name <directory_name>
cp -i <source> <destination>
mv -i <source> <destination>
rm -i <file_name>
mkdir -p <directory_path>
tree
rename <expression> <replacement> <files>
sort <file_name>
uniq <file_name>
wc <file_name>
cut -d <delimiter> -f <field_number> <file_name>
awk '{print $1}' <file_name>
sed 's/<pattern>/<replacement>/' <file_name>
vmstat
iostat
mpstat
uptime
ps aux
kill <pid>
killall <process_name>
pkill <pattern>
groups <username>
usermod -aG <group_name> <username>
chgrp <group_name> <file_name>
visudo
ifup <interface>
ifup eth0
ifdown <interface>
ifdown eth0
ip route
nslookup <domain>
wget <url>
scp <source> <destination>
ssh <username>@<host>
iptables -L
hostname
curl -I <url>
lsblk
fdisk -l
mount <device> <mount_point>
umount <mount_point>
fsck <device>
dd if=<input_file> of=<output_file>
truncate -s 0 <file_name>
xfs_repair <device>
sudo apt autoremove
sudo apt list --upgradable
sudo dpkg -i <package.deb>
sudo dpkg --configure -a
apt-cache search <package_name>
tar -czvf <archive_name>.tar.gz <directory>
tar -xzvf <archive_name>.tar.gz
zip <zip_file>.zip <file1> <file2>
unzip <zip_file>.zip
rsync -av <source> <destination>
alias <shortcut>='<command>'
unalias <shortcut>
date
cal
bc
ssh-keygen
chmod +x <file_name>
stat <file_name>
getfacl <file_name>
setfacl -m u:<username>:rwx <file_name>
Basic Commands
pwd
: Print the current working directory.ls
: List files and directories in the current directory.ls -l
: List files in long format (detailed view).ls -a
: Show hidden files (those starting with.
).cd
: Change the current directory.cd ..
: Go up one directory.cd ~
: Go to the home directory.mkdir <directory_name>
: Create a new directory.rmdir <directory_name>
: Remove an empty directory.rm <file_name>
: Remove a file.rm -r <directory_name>
: Remove a directory and its contents recursively.touch <file_name>
: Create a new empty file or update the timestamp of an existing file.cp <source> <destination>
: Copy files or directories.cp -r <source_directory> <destination_directory>
: Copy a directory recursively.mv <source> <destination>
: Move or rename files or directories.cat <file_name>
: Concatenate and display the contents of a file.less <file_name>
: View the contents of a file one page at a time.head <file_name>
: Display the first 10 lines of a file.tail <file_name>
: Display the last 10 lines of a file.tail -f <file_name>
: Continuously monitor the end of a file for new lines.System Information
df -h
: Show disk space usage in a human-readable format.du -h <directory_name>
: Show disk usage of a directory and its subdirectories.top
: Display active processes and system resource usage.htop
: Enhanced version oftop
with a user-friendly interface (needs to be installed).uname -a
: Display system information (kernel version, architecture, etc.).free -h
: Show memory usage in a human-readable format.lscpu
: Display information about the CPU architecture.User Management
whoami
: Display the current logged-in user.adduser <username>
: Create a new user.deluser <username>
: Delete a user.passwd <username>
: Change the password for a user.su <username>
: Switch to another user (requires password).sudo <command>
: Execute a command with superuser (admin) privileges.Package Management (APT)
sudo apt update
: Update the package list.sudo apt upgrade
: Upgrade installed packages to their latest versions.sudo apt install <package_name>
: Install a new package.sudo apt remove <package_name>
: Remove an installed package.sudo apt search <package_name>
: Search for a package in the repositories.sudo apt show <package_name>
: Show details about a package.Networking
ifconfig
: Display network interfaces and their configurations (deprecated; useip
).ip a
: Show all network interfaces and their IP addresses.ping <hostname>
: Check connectivity to a host by sending ICMP echo requests.traceroute <hostname>
: Show the route packets take to a network host.netstat -tuln
: Display active network connections and listening ports.curl <url>
: Fetch content from a URL.File Permissions
chmod <permissions> <file_name>
: Change the permissions of a file or directory.chmod 755 <file_name>
: Set read, write, and execute permissions for the owner, and read and execute permissions for group and others.chown <user>:<group> <file_name>
: Change the ownership of a file or directory.Searching and Finding Files
find <directory> -name <file_name>
: Search for files in a directory hierarchy.grep <pattern> <file_name>
: Search for a specific pattern in a file.locate <file_name>
: Quickly find the location of a file (requiresmlocate
package to be installed).System Control
shutdown
: Shut down the system.shutdown -h now
: Shut down immediately.reboot
: Restart the system.systemctl <action> <service_name>
: Control system services (start, stop, restart, enable, disable).Miscellaneous
history
: Show the command history.clear
: Clear the terminal screen.echo <text>
: Display a line of text.man <command>
: Display the manual page for a command, providing details on its usage.File and Directory Operations
find <directory> -type f -name <file_name>
: Find files by name in a specific directory.find <directory> -type d -name <directory_name>
: Find directories by name.cp -i <source> <destination>
: Copy files with confirmation before overwriting.mv -i <source> <destination>
: Move files with confirmation before overwriting.rm -i <file_name>
: Remove a file with confirmation.mkdir -p <directory_path>
: Create a directory and parent directories as needed.tree
: Display a directory structure in a tree format (requires installation).rename <expression> <replacement> <files>
: Rename files based on a regex expression (use with caution).Text Processing
sort <file_name>
: Sort lines in a text file.uniq <file_name>
: Report or omit repeated lines in a file.wc <file_name>
: Count lines, words, and characters in a file.cut -d <delimiter> -f <field_number> <file_name>
: Extract specific fields from a file.awk '{print $1}' <file_name>
: Process and analyze text files (prints the first column).sed 's/<pattern>/<replacement>/' <file_name>
: Stream editor for filtering and transforming text.System Monitoring and Management
vmstat
: Report virtual memory statistics.iostat
: Report CPU and I/O statistics (requires installation).mpstat
: Show CPU usage (requires installation).uptime
: Show how long the system has been running and load averages.ps aux
: Display a snapshot of current processes with detailed information.kill <pid>
: Terminate a process by its process ID.killall <process_name>
: Terminate all processes by name.pkill <pattern>
: Kill processes based on a pattern.User and Group Management
groups <username>
: Display the groups a user belongs to.usermod -aG <group_name> <username>
: Add a user to a group.chgrp <group_name> <file_name>
: Change the group ownership of a file.visudo
: Safely edit the sudoers file to manage user privileges.Networking
ifup <interface>
: Bring a network interface up (e.g.,ifup eth0
).ifdown <interface>
: Bring a network interface down (e.g.,ifdown eth0
).ip route
: Show the routing table.nslookup <domain>
: Query DNS to obtain domain name or IP address mapping.wget <url>
: Download files from the web.scp <source> <destination>
: Securely copy files between hosts over SSH.ssh <username>@<host>
: Connect to a remote server via SSH.iptables -L
: List firewall rules (requires sudo privileges).hostname
: Display the current hostname of the system.curl -I <url>
: Fetch the HTTP headers of a URL.Disk and Filesystem Management
lsblk
: List all block devices (disks and partitions).fdisk -l
: List disk partitions (requires sudo).mount <device> <mount_point>
: Mount a filesystem.umount <mount_point>
: Unmount a filesystem.fsck <device>
: Check and repair a filesystem.dd if=<input_file> of=<output_file>
: Convert and copy files (often used for disk images).truncate -s 0 <file_name>
: Reduce the size of a file to zero bytes.xfs_repair <device>
: Repair an XFS filesystem (requires the device to be unmounted).Package Management (Advanced)
sudo apt autoremove
: Remove unnecessary packages that were automatically installed.sudo apt list --upgradable
: List packages that can be upgraded.sudo dpkg -i <package.deb>
: Install a .deb package manually.sudo dpkg --configure -a
: Reconfigure packages that were not configured correctly.apt-cache search <package_name>
: Search for a package in the repository cache.Backup and Compression
tar -czvf <archive_name>.tar.gz <directory>
: Create a compressed tarball.tar -xzvf <archive_name>.tar.gz
: Extract a compressed tarball.zip <zip_file>.zip <file1> <file2>
: Create a zip archive.unzip <zip_file>.zip
: Extract a zip archive.rsync -av <source> <destination>
: Sync files and directories between locations.Miscellaneous
alias <shortcut>='<command>'
: Create an alias for a command.unalias <shortcut>
: Remove an alias.date
: Display the current date and time.cal
: Show the calendar for the current month.bc
: Basic calculator for mathematical operations.ssh-keygen
: Generate SSH key pairs for secure authentication.Permissions and Ownership
chmod +x <file_name>
: Make a script executable.stat <file_name>
: Display detailed file or filesystem status.getfacl <file_name>
: Get file access control lists (requires installation).setfacl -m u:<username>:rwx <file_name>
: Set file access control lists for specific users.