Go Skills

Linux commands you should know

Linux commands

  • ls: Lists directory contents.
ls
ls -l
ls -a
  • cd: Changes the current directory.
cd /path/to/directory
cd ..
  • pwd: Prints the current working directory.
  • mkdir: Creates a new directory.
mkdir directory_name
  • rm: Removes files and directories.
rm file_name
rm -r directory_name
  • cp: Copies files and directories.
cp file_name new_file_name
cp -r directory_name new_directory_name
  • mv: Moves or renames files and directories.
mv file_name new_location/file_name
mv old_name new_name
  • cat: Concatenates and displays file content.
cat file_name
  • grep: Searches for patterns in files.
grep "pattern" file_name
  • chmod: Changes the permissions of files and directories.
chmod 644 file_name
chmod +x script_name
  • chown: Changes the ownership of files and directories.
chown user_name file_name
chown -R user_name directory_name
  • ssh: Connects to a remote server via SSH.
ssh username@remote_host
  • scp: Copies files between local and remote servers using SSH.
scp file_name username@remote_host:/remote/directory
scp username@remote_host:/remote/file_name /local/directory
  • wget: Downloads files from the web.
wget https://example.com/file_name
  • tar: Archives or extracts files.
tar -czvf archive.tar.gz directory_name
tar -xzvf archive.tar.gz
  • ps: Displays the currently running processes.
  • top: Shows real-time system resource usage.
  • kill: Terminates processes.
kill process_id
killall process_name
  • ping: Sends ICMP echo requests to test network connectivity.
ping hostname
ping IP_address
  • ifconfig: Configures network interfaces (older command, replaced by ip command in newer distributions).
ifconfig
ifconfig eth0 up
  • netstat: Displays network connections and statistics.
netstat -tuln
netstat -anp | grep LISTEN
  • iptables: Manages firewall rules.
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
  • systemctl: Controls system services (used in systemd-based distributions).
systemctl start service_name
systemctl stop service_name
systemctl restart service_name
  • journalctl: Views system logs (used in systemd-based distributions).
journalctl -u service_name
journalctl -f
  • sudo: Executes commands with administrative privileges.