You are on page 1of 7

Ubuntu server

What is Computer Server?


Computer Server is specific device to handle in and out data. Laptop cannot be used as server
because it cannot handle such high traffic data. A lot of heat will be generated.
Server Types
1. File Server: serves you files .Acts like Remote storage. Multiple users can place, read, and file to
this server.
2. Web Server: serves you as data. When we type google.com, request goes to Google server and
response comes.
3. Mail server: when we send message to friend, message does not go directly to friend. Message
goes to our mail server, then to friends mail server and to his computer.
What is Linux?
Linux is Open Source and UNIX like OS but it does not contain UNIX codes. Linux Kernel is the core
foundation of Linux. It is the open source code that can be modified and redistributed.
What is Ubuntu?
Ubuntu is based on Debian which is also based on Linux. So a group of people took Linux kernel
source code, made modification, added structured, prepared Debian. Then another group modified
source code and redistributed Ubuntu.
Basic Commands
ls

list contents of current directory

blue names indicates folder


cd

change directory

cd /

- return to root directory

cd ~

- return to home directory

cd ..

-return to one directory back

Creating Directory
Mkdir

-creates new directory

Creating new file


Nano ( save with Ctl+O)
Removing file
Rm filename

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

-also wil shutdown and send signal to ACPI

Sudo shutdown r now your message

Adding, removing users and groups. Root previligies


Sudo adduser newuser1
sudo deluser newuser1

adds user
removes user

Cat /etc/passwd

shows all users in server

su newuser1 - sustituting to other user:


Users
Groups

- show users of group the current user in


-shows groups of which the current user in

Groups test1

--shows groups of which the test 1 in

Cat /etc/group - shows all groups in server


Sudo addgroup test1 adds group test1
Sudo groupdel test1

-deletes group 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

is format of changing date. For example,

Sudo date 032314112016.20 Wed March 23 14:11:20 AZT 2016


Installing programs and understanding dependecies
Dependencies are the other files such as libraries,header files that program needs to run.
Sudo apt-get install test1
Sudo apt-get remove test1
Sudo apt-get update

-will install program test1


-will remove program test1
- will update repositories that is used by system to install programs.

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

- will upgrade all your current programs to latest version.

Sudo do-release-upgrade

- will upgrade system itself to newest version.Ubuntu 14 .0 to 15.0

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--

simply means 754.

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

-shows permissions of hello file

#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.

Now lets change user hp to obtain read,write,execute permission on file hello.


Setfacl -m user:hp:rwx hello
Getfacl hello
#file:hello
#owner:jon
#group:jon
User:: rwUser:hp:rwx
Group:rwMask:r-x #effective:r-x
Other:r--So even hp now has additional write exucute(User:hp:rwx) but mask do not have write pemission
(r-x). So user hp will not be allowed to write hello file because as we mentioned firstly mask
permission comes first then users.
Setfacl -x user:jon:rwx hello - this command removes read,write,execute permission for user jon
to hello file.
Managing File Systems
Filesistem , datann(fayl,folder) kompyuter disklrind(hard disk, CDROM, ) v yaxud hard diskin
blglrind (partitionda) nec saxlanlmasn bildirir.Msln:Fat32,NTF,EXT4. gr fayl sistem
mount olubsa ,bizim ora access ola bilrik Umount olubsa ,accesimiz yoxdu yni hmin diski
read,write ed bilmrik.
df h
-sistemde mvcd olan mounted disklri gsterir.
FileSystem
Size
Mounted on
/dev/sda1
109 GB
/
udev
980 Mb
/dev
/dev/sdb2
10 GB
/run
Bu onu gstririki bizim iki diskimiz mvcuddu(sda ve sdb). Sda v sdb-den sonra gln rqmlr
partiton nmrsini gstrir. Sda1- A diskin birinci partitonu. Sdb2-B diskin ikinci partitonu. Ola bilsin
biz kompyur C diskini balamq amma mount elmdiyimiz n df h gstrmiyck onu.
Sudo fdisk -l -kompyutere balanm btn mounted v unmounted olunmu disklri gstrir.
Disk /dev/sda : 109 GB
Device Boot (Partiton)
/dev/sda1
/dev/sda2
/dev/sda5
Disk /dev/sda : 10 GB
Device Boot (Partiton)
/dev/sdb2
Device udev 980 MB
Bu A v B disklrini ,onlarn partitonlarn gstrir. Sda2 v sda5 partitonu mount olunmad n df
h onlar gstrmir.

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

RAID disklrin qurulmas


Raid disklri birldirmk n istifad olunur. Raidin bir nee levelleri var 0-10 aras.
Raid 0 ndi?Raid 0 bir ne diski bir disk kimi birldirir. Msln ,snin iki dn 1 terabaytliq diskin
var .Onlar Raid 0 etsn o iki disk bir disk kimi grsnck .
Raid 1 ndi? Raid 1 bir diskin klonunu xarrr. Msln,bizim iki dn 1 terabaytlq diskimiz var A v
B. gr onlar Raid 1 etsk,A diskind n yazlb pozulsa B d hmin proses ba verck. A diski fail
olsa B diskindn istifad etmk mmkn olacaq nki B A-nn eynisidi.
Raid dzltmk n mdadm proqram yklmk lazmd. Bununn sudo apt-get install mdadm
daxil edirik.
ndi A v B disklrind Raid 1 dzldk v adda olsun /dev/md7.Bununn:
Sudo mdadm create /dev/md7 -level=1 raid-devices=2 /dev/sda1 /dev/sdb1

You might also like