0% found this document useful (0 votes)
15 views6 pages

Linux_command

Uploaded by

zxalif2222
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

Linux_command

Uploaded by

zxalif2222
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

ls: List directory contents

Example: ls -l (display in long format)

cd: Change directory


Example: cd /path/to/directory (change to a specific directory)

pwd: Print working directory (displays current directory)

mkdir: Make directory


Example: mkdir new_directory (create a new directory)

rmdir: Remove directory


Example: rmdir directory_name (remove an empty directory)

cp: Copy files and directories


Example: cp file.txt destination/ (copy file to a destination)

mv: Move or rename files and directories


Example: mv file.txt new_location/ (move file to a new location)

rm: Remove files and directories


Example: rm file.txt (remove a file)

touch: Create an empty file or update file timestamps


Example: touch file.txt (create an empty file)

cat: Concatenate and display files


Example: cat file.txt (display the contents of a file)

less: View file contents with pagination


Example: less file.txt (display contents with pagination)

head: Display the beginning of a file


Example: head -n 5 file.txt (display the first 5 lines)

tail: Display the end of a file


Example: tail -n 10 file.txt (display the last 10 lines)

grep: Search for patterns in files


Example: grep "pattern" file.txt (search for a pattern in a file)

find: Search for files and directories


Example: find /path/to/search -name "file.txt" (search for a file)

chmod: Change file permissions


Example: chmod 755 file.txt (set file permissions to read, write, and
execute for the owner, and read and execute for others)

chown: Change file ownership


Example: chown user:group file.txt (change the owner and group of a file)

chgrp: Change group ownership


Example: chgrp group file.txt (change the group of a file)

ln: Create links between files


Example: ln -s source_file link_name (create a symbolic link to a file)

tar: Archive files


Example: tar -cvf archive.tar file1 file2 (create a tar archive of files)
gzip: Compress files
Example: gzip file.txt (compress a file)

gunzip: Decompress files


Example: gunzip file.txt.gz (decompress a file)

ssh: Secure Shell remote login


Example: ssh user@hostname (connect to a remote server)

scp: Securely copy files between hosts


Example: scp file.txt user@hostname:/path/to/destination (copy file to a
remote server)

ping: Send ICMP echo requests to a host


Example: ping google.com (check connectivity to a host)

ifconfig: Configure network interfaces


Example: ifconfig eth0 up (activate a network interface)

netstat: Network statistics


Example: netstat -tuln (display open network ports)

wget: Download files from the web


Example: wget http://example.com/file.txt (download a file from a URL)

curl: Transfer data from or to a server


Example: curl http://example.com (fetch the content of a URL)

man: Display manual pages


Example: man ls (display the manual page for the ls command)

uname: Print system information


Example: uname -a (display all system information)

whoami: Print the current user name


Example: whoami (display the current username)

history: Display command history


Example: history (display the command history)

ps: Display process status


Example: ps aux (display all running processes)

kill: Terminate processes


Example: kill 1234 (terminate process with PID 1234)

top: Monitor system activity


Example: top (display real-time system information)

df: Display disk space usage


Example: df -h (display disk space usage in a human-readable format)

du: Estimate file and directory space usage


Example: du -sh directory (estimate disk space usage of a directory)

mount: Mount filesystems


Example: mount /dev/sdb1 /mnt (mount a device to a directory)
umount: Unmount filesystems
Example: umount /mnt (unmount a device from a directory)

apt-get: Package handling utility (Ubuntu/Debian)


Example: apt-get install package_name (install a package)

yum: Package manager (CentOS/Fedora)


Example: yum install package_name (install a package)

systemctl: Control the systemd system and service manager


Example: systemctl start service_name (start a service)

service: Run a System V init script


Example: service apache2 restart (restart the Apache service)

useradd: Create a new user


Example: useradd newuser (create a new user account)

passwd: Change user password


Example: passwd username (change the password for a user)

usermod: Modify user account


Example: usermod -aG group username (add a user to a group)

userdel: Delete a user account


Example: userdel username (delete a user account)

groupadd: Create a new group


Example: groupadd newgroup (create a new group)

groupmod: Modify a group


Example: groupmod -n newname groupname (rename a group)

groupdel: Delete a group


Example: groupdel groupname (delete a group)

su: Switch user


Example: su - username (switch to another user)

sudo: Execute a command as another user


Example: sudo command (run a command with superuser privileges)

history: Display command history


Example: history (display the command history)

ssh-keygen: Generate SSH key pairs


Example: ssh-keygen (generate a new SSH key pair)

scp: Securely copy files between hosts


Example: scp file.txt user@hostname:/path/to/destination (copy file to a
remote server)

diff: Compare files line by line


Example: diff file1.txt file2.txt (compare two files)

sed: Stream editor for text transformation


Example: sed 's/pattern/replacement/g' file.txt (replace all occurrences of
a pattern with a replacement)
awk: Text processing language
Example: awk '{ print $1 }' file.txt (print the first column of a file)

sort: Sort lines of text files


Example: sort file.txt (sort lines in ascending order)

cut: Remove sections from files


Example: cut -d',' -f2 file.csv (extract the second column from a CSV file)

tar: Archive files


Example: tar -cvf archive.tar file1 file2 (create a tar archive of files)

gzip: Compress files


Example: gzip file.txt (compress a file)

gunzip: Decompress files


Example: gunzip file.txt.gz (decompress a file)

find: Search for files and directories


Example: find /path/to/search -name "file.txt" (search for a file)

xargs: Execute commands from standard input


Example: find /path/to/files -type f | xargs rm (delete multiple files)

crontab: Schedule commands to run at fixed times


Example: crontab -e (edit the user's cron jobs)

at: Schedule commands to run once


Example: echo "command" | at 12:30 (schedule a command to run at 12:30)

curl: Transfer data from or to a server


Example: curl http://example.com (fetch the content of a URL)

wget: Download files from the web


Example: wget http://example.com/file.txt (download a file from a URL)

echo: Display a line of text


Example: echo "Hello, world!" (display "Hello, world!")

tee: Read from standard input and write to standard output and files
Example: echo "Hello" | tee file.txt (write "Hello" to a file and display
it)

alias: Create an alias for a command


Example: alias ll="ls -l" (create an alias 'll' for 'ls -l')

source: Execute commands from a file in the current shell


Example: source script.sh (execute commands from a script file)

grep: Search for patterns in files


Example: grep "pattern" file.txt (search for a pattern in a file)

wc: Word, line, character, and byte count


Example: wc -l file.txt (count the number of lines in a file)

awk: Text processing language


Example: awk '{ print $1 }' file.txt (print the first column of a file)

cut: Remove sections from files


Example: cut -d',' -f2 file.csv (extract the second column from a CSV file)

sed: Stream editor for text transformation


Example: sed 's/pattern/replacement/g' file.txt (replace all occurrences of
a pattern with a replacement)

tar: Extract files from an archive


Example: tar -xvf archive.tar (extract files from a tar archive)

gunzip: Decompress files


Example: gunzip file.txt.gz (decompress a file)

zip: Create a zip archive


Example: zip archive.zip file1 file2 (create a zip archive of files)

unzip: Extract files from a zip archive


Example: unzip archive.zip (extract files from a zip archive)

ln: Create links between files


Example: ln -s source_file link_name (create a symbolic link to a file)

df: Display disk space usage


Example: df -h (display disk space usage in a human-readable format)

du: Estimate file and directory space usage


Example: du -sh directory (estimate disk space usage of a directory)

mount: Mount filesystems


Example: mount /dev/sdb1 /mnt (mount a device to a directory)

umount: Unmount filesystems


Example: umount /mnt (unmount a device from a directory)

uname: Print system information


Example: uname -a (display all system information)

lspci: List all PCI devices


Example: lspci (list PCI devices)

lsusb: List USB devices


Example: lsusb (list USB devices)

ifconfig: Configure network interfaces


Example: ifconfig eth0 up (activate a network interface)

netstat: Network statistics


Example: netstat -tuln (display open network ports)

iptables: Administration tool for IPv4 packet filtering and NAT


Example: iptables -A INPUT -p tcp --dport 80 -j ACCEPT (allow incoming HTTP
traffic)

hostname: Print or set system hostname


Example: hostname (display the system hostname)

date: Print or set the system date and time


Example: date (display the current date and time)

cal: Display a calendar


Example: cal (display the calendar for the current month)

clear: Clear the terminal screen


Example: clear (clear the terminal screen)

shutdown: Shutdown or restart the system


Example: shutdown -h now (shut down the system immediately)

exit: Exit the current shell or terminal


Example: exit (exit the current shell)

These are just a few examples of the many Linux commands available. The list covers
a range of commands for file management, process management, networking, package
management, system administration, and more.

You might also like