0% found this document useful (0 votes)
5 views3 pages

Unix Zip Command Overview

The document is a comprehensive guide to Unix commands, covering various categories including directory navigation, file operations, viewing file content, file permissions, and more. It provides specific command syntax and examples for each category, making it a useful reference for users. Additionally, it includes sections on advanced text tools and shell scripting basics.

Uploaded by

premchandchegg
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)
5 views3 pages

Unix Zip Command Overview

The document is a comprehensive guide to Unix commands, covering various categories including directory navigation, file operations, viewing file content, file permissions, and more. It provides specific command syntax and examples for each category, making it a useful reference for users. Additionally, it includes sections on advanced text tools and shell scripting basics.

Uploaded by

premchandchegg
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

Complete Unix Command Guide

Complete Unix Command Reference

1. DIRECTORY & FILE NAVIGATION


------------------------------
pwd - Print current directory
cd /path - Change to directory
cd .. - Go to parent directory
cd - - Go to previous directory
ls - List files
ls -al - List all files with details

2. FILE OPERATIONS
------------------
touch [Link] - Create file
cp file1 file2 - Copy file
cp -r dir1 dir2 - Copy directory
mv old new - Move or rename
rm file - Delete file
rm -rf dir - Delete folder recursively
mkdir folder - Create directory
rmdir folder - Delete empty directory

3. VIEWING FILE CONTENT


------------------------
cat file - Show content
less file - View content page-wise
more file - Similar to less
head file - First 10 lines
tail file - Last 10 lines
tail -f file - Monitor live updates

4. FILE PERMISSIONS
-------------------
chmod 755 file - rwxr-xr-x permission
chmod u+x file - Add execute to user
chown user:group file - Change owner
ls -l - View permissions

5. FINDING FILES
----------------
find /path -name "*.log" - Find .log files
find . -type f -mtime -1 - Modified in last 1 day
find . -size +100M - Larger than 100MB
locate filename - Locate quickly

6. TEXT SEARCHING
-----------------
grep "text" file - Search text
Complete Unix Command Guide

grep -i "text" - Case-insensitive


grep -r "text" dir - Recursive search
grep -v "text" - Exclude text
grep -A 3 -B 2 "fail" - Contextual lines

7. DISK USAGE
-------------
df -h - Disk usage
du -sh * - Size of files/folders
du -ah | sort -rh | head -10 - Top 10 biggest

8. PROCESS MANAGEMENT
---------------------
ps -ef - List processes
top - Live usage
kill PID - Kill process
kill -9 PID - Force kill
jobs, bg, fg - Job control

9. NETWORKING
-------------
ping host - Ping test
netstat -tulnp - Open ports
curl URL - Fetch data
wget URL - Download
scp file user@host:/path - Copy to remote
ssh user@host - SSH login

10. ARCHIVE & COMPRESS


----------------------
tar -cvf [Link] dir - Create archive
tar -xvf [Link] - Extract
tar -czvf [Link] dir - Gzip tar
gzip/gunzip file - Compress/decompress
zip/unzip file - Zip/unzip

11. CRONTAB
-----------
crontab -l - List jobs
crontab -e - Edit cron jobs
crontab -r - Remove jobs

Syntax: * * * * * /[Link]

12. SYSTEM INFO


---------------
uname -a - System info
uptime - How long running
whoami - Current user
hostname - Hostname
Complete Unix Command Guide

date - Current date/time


cal - Calendar

13. ADVANCED TEXT TOOLS


------------------------
AWK:
awk '{print $1, $3}' [Link]
awk -F ',' '{print $2}' [Link]

SED:
sed 's/old/new/g' [Link]
sed -n '5,10p' [Link]

14. SHELL SCRIPTING BASICS


---------------------------
#!/bin/bash
echo "Hello, $USER"
now=$(date)
echo "Current time: $now"

Loops:
for i in {1..5}; do echo "Number: $i"; done

If:
if [ -f /etc/passwd ]; then echo "Exists"; fi

Common questions

Powered by AI

Using 'grep -r "text" dir' is advantageous because it searches recursively through all files and subdirectories for occurrences of 'text'. This saves time and effort compared to searching each file individually, especially when dealing with large projects spanning multiple directories. It helps in efficiently locating patterns across entire directory trees .

A crontab entry has the syntax '* * * * * /command.sh', representing minute, hour, day of month, month, and day of week respectively, followed by the command to execute. This structure facilitates systematic automation by allowing precise scheduling of tasks, ensuring repeated execution at defined intervals without manual initiation, which is essential for maintenance and task consistency .

The 'df -h' command reports the disk space usage of the entire filesystem in a readable format, giving an overview of available and used space. In contrast, 'du -sh *' provides a summary of the space utilized by specific files and directories within the current directory. Together, they offer both a holistic view and detailed per-directory insights into disk usage .

The command 'chmod 755 file' sets the file permissions to 'rwxr-xr-x'. The significance is it grants the owner read, write, and execute permissions, while others (group and public) receive read and execute permissions. This ensures the file is executable by everyone but modifiable only by the owner, thus maintaining security while allowing broader access .

The 'tail -f' command enhances file monitoring because it allows users to view updates to a file in real-time, which is crucial for log file analysis. This means that as new lines are added to the log file, they appear instantly on the screen, aiding in timely diagnostics and insights in dynamic environments where logs are continually updated .

The 'pwd' command is used to determine the current directory in a Unix system. This is useful because, during a session involving multiple directory changes, knowing the current directory helps the user understand the context for file operations and script execution, ensuring that commands are applied to the intended directory .

'awk' is beneficial for text processing in Unix scripts due to its ability to process column-based data efficiently, which is common in CSV files. By using its pattern scanning and text processing capabilities, like 'awk -F ',' {print $2}' for extracting the second column, 'awk' allows detailed manipulation of structured data, essential for reporting and data analysis tasks within scripts .

To create a compressed archive of a directory, use 'tar -czvf file.tar.gz dir' to compress the directory into a gzip format archive. To ensure that the contents are decompressed correctly, use 'tar -xvf file.tar.gz' which will extract the files back into the original directory structure .

A user might prefer 'scp' over 'wget' when secure file transfers between systems are required. 'scp' uses SSH protocol to securely copy files to a remote host, ensuring data integrity and security. This is ideal when both confidentiality and authentication are concerns. 'wget', on the other hand, retrieves files from web servers without inherent security layers provided by 'scp' .

The 'ps -ef' command plays a vital role in process management by listing all currently running processes in a detailed, extensible format. It is crucial for systems administration because it aids in monitoring process activity, diagnosing issues by identifying resource hogs or unexpected processes, and managing system stability and performance .

You might also like