| name | linux-basics |
| description | How to work with Linux fundamentals including file permissions, user management, process control, and system navigation. Use this skill whenever the user needs help with Linux commands, file operations, permissions, users/groups, processes, or basic system administration tasks. Trigger for any Linux-related questions about navigating directories, managing files, understanding permissions, running commands, or troubleshooting basic system issues. |
Linux Basics
This skill covers fundamental Linux operations that every user should know. Use it for file management, permissions, user administration, process control, and system navigation.
When to Use This Skill
Use this skill when the user:
- Needs help with Linux commands and their syntax
- Wants to understand file permissions and how to modify them
- Is working with users, groups, or sudo privileges
- Needs to manage processes (start, stop, monitor)
- Is navigating the filesystem or working with directories
- Wants to understand basic system administration concepts
- Is troubleshooting common Linux issues
File System Navigation
Basic Commands
pwd
ls
ls -la
ls -lh
cd /path
cd ..
cd ~
cd -
Understanding Paths
- Absolute path: Starts from root
/ (e.g., /home/user/documents)
- Relative path: From current directory (e.g.,
./documents or ../other)
- Special paths:
. = current directory
.. = parent directory
~ = home directory
~/ = home directory with trailing slash
File Operations
mkdir directory_name
mkdir -p a/b/c
touch filename
rm filename
rm -r directory
rm -rf directory
cp source dest
cp -r source dest
mv source dest
ln -s target link
File Permissions
Understanding Permissions
Permissions are shown as 10 characters: -rwxr-xr--
Position: 0123456789
│││││││││└─ Other (world) permissions
│││││││└─── Group permissions
│││││└───── User (owner) permissions
│││└─────── Type (d=directory, -=file, l=link)
│└───────── Setuid bit
└────────── Setgid bit
Permission values:
r = read (4)
w = write (2)
x = execute (1)
- = no permission (0)
Modifying Permissions
chmod u+x file
chmod 755 file
chmod 644 file
chmod g-w file
chmod a+r file
chmod -R 755 dir/
Ownership
chown user file
chown user:group file
chown -R user:group dir
Checking Permissions
ls -l filename
stat filename
namei -l filename
User and Group Management
Viewing Users and Groups
whoami
id
who
w
last
cat /etc/passwd
cat /etc/group
groups username
id username
User Administration (requires sudo)
sudo useradd username
sudo usermod -aG group username
sudo usermod -L username
sudo usermod -U username
sudo passwd username
sudo userdel username
sudo userdel -r username
Group Administration (requires sudo)
sudo groupadd groupname
sudo groupmod -n newname old
sudo groupdel groupname
Sudo Privileges
sudo command
sudo -i
sudo -u user command
sudo -l
Process Management
Viewing Processes
ps aux
ps -ef
ps -u username
pgrep -l pattern
pidof program
top
htop
Process Control
kill PID
kill -9 PID
killall program
pkill pattern
fg
bg
jobs
Ctrl+Z
Ctrl+C
Background Execution
command &
nohup command &
screen -S name
screen -r name
System Information
Hardware and System
uname -a
hostname
uptime
free -h
df -h
du -sh directory
lscpu
lsblk
Network
ip addr
ifconfig
netstat -tulpn
ss -tulpn
ping hostname
traceroute hostname
nslookup domain
dig domain
Logs
journalctl -xe
tail -f /var/log/syslog
dmesg
last
Common Patterns
Finding Files
find /path -name "*.txt"
find /path -type f -size +100M
find /path -mtime -7
find /path -user username
locate filename
Text Processing
cat file
head -n 20 file
tail -n 20 file
tail -f file
grep "pattern" file
grep -r "pattern" dir/
grep -i "pattern" file
wc -l file
Compression
tar -czf archive.tar.gz dir/
tar -xzf archive.tar.gz
tar -cjf archive.tar.bz2 dir/
tar -xjf archive.tar.bz2
zip -r archive.zip dir/
unzip archive.zip
Safety Tips
- Always check before deleting: Use
ls before rm -rf
- Test commands: Run without
-r or -f flags first
- Use
sudo carefully: Understand what you're running as root
- Backup important data: Before making system changes
- Check permissions: Ensure you have the right to modify files
- Read man pages:
man command for detailed documentation
Quick Reference
| Task | Command |
|---|
| List files | ls -la |
| Change directory | cd path |
| Copy file | cp source dest |
| Move file | mv source dest |
| Delete file | rm file |
| Create directory | mkdir dir |
| View file | cat file or less file |
| Edit file | nano file or vim file |
| Search text | grep "pattern" file |
| Find file | find /path -name "*" |
| Check permissions | ls -l |
| Change permissions | chmod 755 file |
| Change owner | chown user:group file |
| View processes | ps aux |
| Kill process | kill PID |
| Check disk space | df -h |
| Check memory | free -h |
| View logs | journalctl -xe |