MOST WIDELY USED HARD COMMANDS
MOST WIDELY USED HARD COMMANDS
Bash
Copy code
# View file content
cat file.txt
# View file with pagination
less file.txt
# Show first 10 lines
head file.txt
# Show last 10 lines
tail file.txt
# Follow file changes in real-time (logs)
tail -f /var/log/syslog
# Create or overwrite a file
echo "Hello World" > hello.txt
# Append to a file
echo "Another line" >> hello.txt
# Open file in nano editor
nano file.txt
Bash
Copy code
# Copy file
cp file.txt backup.txt
# Copy directory recursively
cp -r my_folder backup_folder
# Move or rename file
mv oldname.txt newname.txt
# Move file to another directory
mv file.txt /path/to/destination/
Bash
Copy code
# Search for a word in a file
grep "keyword" file.txt
# Search recursively in a directory
grep -r "keyword" /path/to/search/
# Find files by name
find /path/to/search -name "*.txt"
# Find files modified in last 1 day
find . -mtime -1
Bash
Copy code
# Show file permissions
ls -l
# Change file permissions (read/write/execute)
chmod 755 script.sh
# Change file owner
sudo chown user:group file.txt
PAGE 3