0% found this document useful (0 votes)
9 views

4-Linux Commands and Shell Scripts-26-07-2024 (1)

linux

Uploaded by

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

4-Linux Commands and Shell Scripts-26-07-2024 (1)

linux

Uploaded by

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

File and Directory Management

• ls: ls -l /home
• cd: cd /var/log
• pwd: pwd
• mkdir: mkdir new_directory
• rmdir: rmdir empty_directory
• rm: rm file.txt
• cp: cp source.txt destination.txt
• mv: mv oldname.txt newname.txt
• touch: touch newfile.txt
• chmod: chmod 777 script.sh
• chown: chown user:group file.txt
• ln: ln -s /path/to/file symlink

2. File Viewing and Editing

• cat: cat file.txt


• more: more file.txt
• less: less file.txt
• head: head -n 10 file.txt
• tail: tail -n 10 file.txt
• nano: nano file.txt
• vi/vim: vi file.txt

3. File Compression and Archiving

• tar: tar -cvf archive.tar /path/to/directory


• gzip: gzip file.txt
• gunzip: gunzip file.txt.gz
• zip: zip archive.zip file1.txt file2.txt
• unzip: unzip archive.zip

4. File Search

• find: find /home -name "*.txt"


• locate: locate file.txt
• grep: grep "search_term" file.txt

5. System Information and Management

• uname: uname -a
• df: df -h
• du: du -sh /path/to/directory
• top: top
• htop: htop
• ps: ps aux
• free: free -m
• uptime: uptime
• hostname: hostname

6. User and Permission Management

• whoami: whoami
• sudo: sudo apt-get update
• su: su -
• useradd: sudo useradd newuser
• usermod: sudo usermod -aG groupname username
• userdel: sudo userdel username
• groupadd: sudo groupadd newgroup
• groupdel: sudo groupdel oldgroup

7. Networking

• ping: ping google.com


• ifconfig: ifconfig eth0
• ip: ip addr show
• netstat: netstat -tuln
• ss: ss -tuln
• scp: scp file.txt user@remote_host:/path/to/destination
• ssh: ssh user@remote_host
• wget: wget http://example.com/file.txt
• curl: curl -O http://example.com/file.txt

8. Package Management
• Debian-based (e.g., Ubuntu):
◦ apt-get: sudo apt-get install package_name
◦ apt-cache: apt-cache search package_name
◦ dpkg: sudo dpkg -i package.deb
• Red Hat-based (e.g., CentOS, Fedora):
◦ yum: sudo yum install package_name
◦ dnf: sudo dnf install package_name
◦ rpm: sudo rpm -i package.rpm
9. Disk Management

• fdisk: sudo fdisk /dev/sda


• mkfs: sudo mkfs.ext4 /dev/sda1
• mount: sudo mount /dev/sda1 /mnt
• umount: sudo umount /mnt
• fsck: sudo fsck /dev/sda1

10. Process Management

• kill: kill 1234


• killall: killall processname
• pkill: pkill -9 processname
• nohup: nohup command &

11. System Shutdown and Reboot

• shutdown: sudo shutdown -h now


• reboot: sudo reboot
• halt: sudo halt

12. Permissions and Ownership

• chmod: chmod 644 file.txt


• chown: chown user:group file.txt
• chgrp: chgrp group file.txt

You might also like