Linux commands
Eng .David Kamal
System Information Commands
uname -a shows Linux system info
uptime displays system running/lifetime
hostname shows the system hostname
hostname -I shows IP addresses of the host
last reboot displays system reboot history
date displays current date and time
cal displays monthly calendar
man To show the manual pages
User Information Commands
shows user & group ids of the
id
current user
last shows the last users logged on
whoami shows who you are logged in as
sudo adduser username To add a new user
sudo passwd -l 'username' To change the password of a user
sudo userdel -r 'username' To remove a newly created user
File commands
shows file type and access
ls -l
permission
ls -a lists also hidden files
ls -al lists files and directories detailly
pwd shows present directory
mkdir directory creates a directory
1|Page
cd Change directory
rm xyz deletes file xyz
deletes directory /xyz and its
rm -r /xyz
contents recursively
cp aaa bbb copies aaa file to bbb file
mv aaa bbb renames or moves file aaa to file bbb
touch abc creates an empty file named abc
cat abc used to view file abc
head abc displays first 10 lines of file abc
tail abc displays last 10 lines of file abc
file abc gets type of abc
open lets you open a file
File Permission
changes ownership of a
chown user
file/directory
changes user and group for a file or
chown user:group filename
directory
grep x file searches for x in file
r (read) permission, 4
w (write) permission, 2
File permission
x (execute) permission, 1
-= no permission
2|Page
File Owner owner/group/everyone
777 | Owner, Group, Everyone
has rwx permissions
744 | Owner has rwx
permission,Group, Everyone has
r permission
File Permissions Examples
755 | Owner has rwx permission,
Group, Everyone has rx
permissions
776 | Owner, Group has rwx
permission, Everyone has rw
3|Page