Jul 31, 2024
ls
Commandls
lists files and directories.-l
(long listing): Provides detailed info (links, rights, owner, group, size, date).-a
(all): Shows hidden files.-t
(time): Orders by modification date.-h
(human-readable): Displays file sizes in KB, MB, etc.ls -lath
for comprehensive listing.cd
Commandcd [directory_name]
cd -
: Switches to the previous directory.cd ..
: Moves up one level.cd /path/to/dir
: Directly navigate to a directory.Tab
for auto-complete directory names.cd ~
or just cd
.PWD
Commandpwd
shows the current directory.touch
Commandtouch file1 file2 ...
mkdir
Commandmkdir dir1 dir2 ...
-p
: Creates parent directories as needed.-m
: Sets permissions (e.g., mkdir -m 777 dir
).cp
Commandcp source destination
cp -r source_dir destination_dir
rm
Commandrm file
rm -r dir
rm -rf dir
mv
Commandmv old_name new_name
or mv file /new/path
du
Commanddu [options] [dir]
-h
: Human-readable sizes.-s
: Summarize total size.chmod
Commandchmod [permissions] file/dir
chmod 777 file
: Full permissions.chmod u+x file
: Adds execute permission to the user.chown
Commandchown user:group file/dir
chown root:users file
chown user file
cat
Commandcat file
cat file1 file2 > combined_file
cat file >> existing_file
tail
Commandtail file
-n [number]
: Number of lines to show.-f
: Follow file updates.head
Commandhead file
-n [number]
: Number of lines to show.less
& more
Commandsless file
or more file
/pattern
in less
vi
and nano
ps
Commandps aux
for detailed list.aux
: All processes with details.top
Commandtop
top -u username
kill
Commandkill PID
kill -9 PID
command &
jobs
fg %job_number
ifconfig
and ip
ifconfig
or ip addr
ip route
ip addr add 192.168.1.1/24 dev eth0
ip addr del 192.168.1.1/24 dev eth0
netstat
and ss
netstat -l
or ss -t
ssh
and scp
ssh user@host
scp source user@host:/path
uname
Commanduname -a
df
Commanddf -h
find
Commandfind /path -name "pattern"
find /path -size +1M
find /path -mtime -30
grep
Commandgrep "pattern" file
tar
Commandtar czf archive.tar.gz files
tar xzf archive.tar.gz
tar rf archive.tar file
gzip
Commandgzip file
gunzip file.gz
gzip -l archive.tar.gz
useradd
and userdel
useradd username
userdel username
groupadd
and groupdel
groupadd groupname
groupdel groupname