Jul 31, 2024
ls
Command-l
: Long listing format (details like permissions, owner, size, modification date).-a
: Includes hidden files (files starting with .
).-t
: Sort by modification time (newest first).-h
: Human-readable file sizes.ls -lath
.-R [directory]
: Lists directory contents recursively.ls -R etc
cd
Commandtab
for auto-complete directory names.cd -
: Switch to the previous directory.cd ..
: Move up one directory level.cd ~
: Move to the home directory.pwd
Commandtouch
Commandtouch file1 file2 file3
mkdir
Command-p
: Create parent directories as needed.-m [permissions]
: Set permissions (e.g., 777) when creating.mkdir -p dir1/dir2/dir3
mkdir -m 777 testdir
cp
Command-r
: Copy directories recursively.-f
: Force overwrite.cp file1 file2
cp -rf dir1 dir2
rm
Command-r
: Remove directories recursively.-f
: Force removal.rm file1
rm -rf directory
mv
Commandmv oldname newname
mv file1 /path/to/destination
du
Command-h
: Human-readable format.-s
: Summarize total.du -sh /var/log
chmod
Commandu
, g
, o
: User, group, other.+
, -
: Add or remove permissions.r
, w
, x
: Read, write, execute.chmod u+x filename
chmod 777 filename
chown
Commandchown user:group filename
chown root:users file1
chown username: filename
cat
Command>
to redirect output.>>
to append to files.cat file1 file2 > newfile
less
and more
Commandsless filename
, more filename
nano
Commandnano filename
vi
Commandvi filename
ps
Commandaux
: Detailed process list.ps aux
top
Command-u [username]
: Filter by user.-p [PID]
: Filter by process ID.top -u root
kill
Command-9 [PID]
: Force kill.kill -9 1234
jobs
, fg
, bg
Commandsjobs
: List background jobs.fg [job]
: Move job to foreground.bg [job]
: Move job to background.ifconfig
and ip
Commandsifconfig
ip addr show
ip route show
netstat
and ss
Commands-l
: Listening ports.-t
: TCP connections.-u
: UDP connections.netstat -ltu
ss -lt
ssh
Commandssh username@hostname
ssh -p [port] username@hostname
scp
Commandscp localfile user@remotehost:/path/to/destination
rsync
Commandrsync -avz /source/ user@remote:/destination/
uname
Command-a
: All information.uname -a
df
Command-h
: Human-readable format.-t
: File system type.df -hT
find
Command-name
: Search by name.-size
: Search by file size.-mtime
: Search by modification time.find /home -name '*.jpg'
find /var/log -size +1M
find /var/log -mtime -30
grep
Command-i
: Case insensitive.-r
: Recursive.grep 'search_string' file
grep -r 'search_string' /path/to/directory
tar
Command-c
: Create.-x
: Extract.-z
: Compress with gzip.-f
: Specify filename.tar -czf archive.tar.gz /path/to/directory
tar -xzf archive.tar.gz
gzip
Command-d
: Decompress.gzip filename
gzip -d filename.gz
useradd
and userdel
Commands-m
: Create home directory.-G [group]
: Add to group.-e [date]
: Set account expiration date.useradd -m -G root username
userdel -r username
groupadd
and groupdel
Commandsgroupadd groupname
groupdel groupname