Jul 31, 2024
ls
Commandls -l
: Long listing format with detailed information (links, ownership, size, date).ls -a
: Includes hidden files.ls -t
: Sorts by modification time.ls -h
: Human-readable file sizes.ls -lath
cd
Commandcd -
: Go back to the previous directory.cd ..
: Move up one directory level.cd ~
: Go to the home directory.pwd
Commandtouch file1 file2 file3
mkdir dir1
mkdir -p parent/child/grandchild
mkdir -m 777 dir
(sets full permissions)cp source_file destination_file
cp -r source_dir destination_dir
rm file
rm -r dir
rm test*
mv source_file destination_file
mv old_name new_name
du
Commanddu -h
: Human-readable sizes.du -s
: Summarize total size.du -sh *
r
(read), w
(write), x
(execute).chmod
chmod u+x file
(user execute), chmod g-w file
(group write)chmod 755 file
(sets rwxr-xr-x)chown
chown user file
chown :group file
chown user:group file
cat
Commandcat file1 file2 > combined_file
cat file3 >> combined_file
tail
Commandtail -n 15 file
: Last 15 lines.tail -f file
: Follow updates in real-time.head
Commandhead -n 15 file
: First 15 lines.less
and more
Commands/pattern
in less
to search.vi
and vim
Editorsvi file
i
to insert text.:wq
nano
Editornano file
ps
Commandps aux
for detailed view.top
Commandtop -u username
top -p PID
kill PID
kill -9 PID
ifconfig
, ip addr
, ip route show
ip addr add 192.168.1.10/24 dev eth0
ip route
ssh user@hostname
scp source_file user@hostname:/path/to/destination
rsync -avz source/ destination/
uname
Commanduname -a
for detailed system info.df
Commanddf -h
find
Commandfind /path -name filename
find /path -size +1M
find /path -mtime -30
grep
Commandgrep 'pattern' filename
tar
Commandtar -cvf archive.tar files
tar -xvf archive.tar
tar -czvf archive.tar.gz files
gzip
Commandgzip file
gunzip file.gz
gzip -l file.gz
useradd username
useradd -m username
userdel username
groupadd groupname
groupdel groupname