Ubuntu Server
Ubuntu Server
change directory
cd /
cd ~
cd ..
Creating Directory
Mkdir
Removing Directory
1)If empty, use rmdir test1
2) if not empty, rmdir test1 will produce error. So use below which will remove recursively all files in
it and directory itself rm R test1
Reading Files & Shell Navigation Tips (TAB, cat, &&)
nano test1 command used to read and write files.
cat test1 used to show contents of file directly to screen.
We can simultaneously execute several commands. For instance
cat test.txt && cd / -This command will show test and go back to root directory successively.
Managing Output
f we open cat syslog for example it will show a ton of information. We can scroll up but it will only
scroll some but then stop.
Cat syslog | less will divide content into pages. Use page down or page up to display info.
Cat syslog | more
will also divide but we cannot go up anymore .Use spacebar to display info.
Cat syslog | grep azer - will only display lines that has azer included.
Copying and Moving files
To move qwert file to home : mv qwert ~
To copy qwert file to home: cp qwert ~
To move directory to root/new : mv R qwert ~/new
To show progress of files(Speed,size,duration) while they are copied
rsync avzP qwert ~/new2
Shutdown
Sudo shutdown h 17:00 System Maintenance. Now other users will see System
Maintenancemessage before 17:00. And system in 17:00 willl shutdown.
Sudo poweroff
adds user
removes user
Cat /etc/passwd
Groups test1
Gift Root Previligies to user: sudo visudo .Then uder root write users name.
Changing User password. Adding,removing users from group
Sudo passwd test1 - to change password of test1
Sudo user can change password of other user without knowing his password.
Sudo adduser test1 testgroup -will add user test1 to testgroup
Sudo deluser test1 testgroup -will del user test1 from testgroup
Help options, Maual of codes.
Man rsync or rsync help.
Change Date and Time
Date views date and time.
Sudo date monthdayhourminutesyear.seconds
Repositories are places that gives indexesto ubuntu server to download programs from.
By updating repositories we will install newer programs.But it does not update current programs
installed.We can manually change repository lists:
Sudo nano /etc/apt/sources.list -blue lines(commented) means those repositories are not
updates when we issue sudo apt-get update.But we can uncomment them and update.
Sudo apt-get upgrade
Sudo do-release-upgrade
Sudo apt-cache search test1 - will search and show related programs to test1
Basic Networking
Ifconfig - same as ipconfig in windows
Ping - same as ping in windows
Sudo nano /etc/hostname - shows and let change hostname of your server
Sudo nano /etc/network/interfaces - shows and let change ipaddresses.Sample output:
iface eth0 inet dhcp means getting ip from dhcp
iface eth0 inet static address 192.168.126.131
netmask 255.255.255.0
gateway 192.168.1.1
sudo ifdown eth0 - will shutdown eth0 interface
sudo ifup eth0 -will bring up eth0 interface
File Permissions. Changing File permissions and owner of file.
ls l - shows file permissions and owner of file in current directory
-rwx r-x r-- - first sign means whether it is file or not(- indicates file,d indicates directory). Rwx
shows permisions of owner of the file. R-x shows permissions of users in the group that the owner of
file is. Rindicates permissions of all other users.
Code of Rwx (7) , rw-(6), r-x(5) ,r--(4). So rwx r-x r--
Chmod 777 test.txt -will change permission of test to rwxrwxrwx . So everyone can
read,write,execute. Write ls l to verify.
Sudo chown root test1.txt - changes owner of test1.txt to root user. Write ls l to verify.
Sudo chgrp root test.txt - changes group of test1.txt file to root group. Root who is owner of file can
change group,owner of file without sudo command.
Access Control Lists(ACL)
ACL used by Windows but can also be used by Linux.ACL helps you to specify futher permissions for
specific users or groups.
Getfacl hello
#file:hello
#owner:jon
#group:jon
User:: rwGroup:rwOther:r--In other words, it is rw- rw- r-Setfacl -m user:jon:rwx hello - this command gives read,write,execute permission for user jon to
hello file. Now lets verify:
Getfacl hello
#file:hello
#owner:jon
#group:jon
User:: rwx
Group:rwOther:r--It became rwx rw- r-Setfacl -m group:jon:rw- hello - this gives read and write permission to group that owns file.
Setfacl -m mask::--- hello
- specifies mask --- for hello file. But what is Mask? Mask is border
limit for users of group that file belong to. So even though,group is granted rwx permissions on file
hello, users on group will not be able read ,write or execute hello file.
Getfacl hello
#file:hello
#owner:jon
#group:jon
User:: rwGroup:rwMask:--#effective:--Other:r--Since we configured mask,now we can see it in output.Now lets give permission read and execute to
user hp for file hello.
Setfacl -m user:hp:r-x hello
Getfacl hello
#file:hello
#owner:jon
#group:jon
User:: rwUser:hp:r-x
Group:rwMask:r-x #effective:r-x
Other:r--So user hp is granted for read and executing file.
Sudo fdisk -disklr zrind mliyyat aparmaq n komandd. Tutaq ki B diskin 1-ci partitonu
silmk istyirik.Bunun B diskine daxil oluruq (sudo fdisk /dev/sdb). Sonra d hrfi daxil
edirik.Partiton nmrsini daxil edirik (1). Artq B diskin 1-ci paritonu silindi v yadda saxlamaq n
w daxil edirik. Verify etmk n sudo fdisk /dev/sdb daxil edirik v artlq 1paritonu yoxdu.
Yeni Partiton dzltmk n is n daxil edirik ,Primary etmk n (p) sonra partition nmrsi
seirik (ms:2),l seirik v enter basrq. ndi is B diskin 2 partitonda EXT4 file system dzldk.
Bununn sudo mkfs.ext4 /dev/sdb1 yazrq. File system nvn sudo fdisk /dev/sdb
gstrmiyck. vzin sudo parted daxil etmliyik.
Amma hld df h sdb2 diskini gstrmiyck nki mount etmmiik onu hl. Indi glin 2ci
partitonu /mtn/sdb folderine mount eliyk. Bununn /mnt da yeni folder dzldirik msln sdb.
Sonra bu komand daxil edirik: sudo mount t ext4 /dev/sdb2 /mnt/sdb . Biz sdb1-d ext4
dzltiyimiz n ext4 daxil etdik amma msln fat32 olasayd sudo mount t ext4 /dev/sdb2
/mnt/sdb .
Sudo umount /dev/sdb2 -B diskin 2ci partitonu unmount edir