A Linux distribution (often called a distro for short) is an operating system made as a collection of software based around the Linux kernel and often around a package management system.[Wikipedia-distro]
[Wikipedia-distro] | http://en.wikipedia.org/wiki/Linux_distribution |
"This is just to announce the imminent completion of a brand-new Linux release, which I'm calling the Debian Linux Release. This is a release that I have put together basically from scratch; in other words, I didn't simply make some changes to SLS and call it a new release. I was inspired to put together this release after running SLS and generally being dissatisfied with much of it, and after much altering of SLS I decided that it would be easier to start from scratch."[Debian-Ian-Murdock] - August 17, 1993
[Debian-Ian-Murdock] | http://groups.google.com/group/comp.os.linux.development/msg/a32d4e2ef3bcdcc6 |
Each distribution fills a specific niche
Gentoo: | source based meta distribution used to create ChromeOS |
---|---|
Android: | Mobile platform using the Linux kernel but its own unique userland |
OpenWRT: | Embedded wifi router distribution |
LTSP: | Thin client distribution used in some K12 schools |
Tails: | Security and privacy focused disto that is livecd/usb based |
CoreOS: | Specialize in massive container deployments |
You name it, there's a distro out there!
CentOS 7
Why?
$ whoami # your username
$ who # who is logged in?
$ w # who is here and what are they doing?
$ id # user ID, group ID, and groups you're in
$ cat /etc/passwd
# username:x:UID:GID:GECOS:homedir:shell
$ useradd $USER # vs adduser, the friendly Ubuntu version
$ userdel $USER
$ passwd
# GECOS: full name, office number and building, office phone extension,
# home phone number (General Electric Comprehensive Operating System)
$ chfn # change GECOS information
$ finger # tells you someone's GECOS info
/etc/shadow
, not /etc/passwd
user@localhost ~ $ ls -l /etc/ | grep shadow
-rw-r----- 1 root shadow 1503 Nov 12 17:37 shadow
$ sudo su -
$ cat /etc/shadow
daemon:*:15630:0:99999:7:::
bin:*:15630:0:99999:7:::
sys:*:15630:0:99999:7:::
mail:*:15630:0:99999:7:::
# name:hash:time last changed: min days between changes: max days
# between changes:days to wait before expiry or disabling:day of
# account expiry
$ chage # change when a user's password expires
sudo
Consult man 5 sudoers
for more information:
# User alias specification
User_Alias CS312_ADMIN = lance, jordane
User_Alias CS312_STUDENT = john, jane
# Runas alias specification
Runas_Alias ADMIN = root, sysadmin
Runas_Alias STUDENT = httpd
# Host alias specification
Host_Alias OSU_NET = 128.193.0.0/16
Host_Alias SERVERS = www, db
# Cmnd alias specification
Cmnd_Alias KILL = /bin/kill
Cmnd_Alias SU = /bin/su
# User privilege specification
root ALL = (ALL) ALL
CS312_ADMIN ALL = NOPASSWD: ALL
CS312_STUDENT OSU_NET = (STUDENT) KILL, SU
$ su joe # become user joe, with THEIR password
$ su # become root, with root's password
$ sudo su - # become root, with your password
$ sudo su joe # become user joe with your password
A dash after su
provides an environment similar to what the user would
expect. Typically a good practice to always use su -
Manage permissions for groups of users
$ groupadd
$ usermod
$ groupmod
$ gpasswd
$ cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
# group name:password or placeholder:GID:member,member,member
Users won't be active in new group until they "log back in"
Files have:
Owner | atime, ctime, mtime |
Group | POSIX ACLs |
Permissions | Spinlock |
Inode | i_ino |
Size | read, write and link count |
Filename |
user@localhost ~ $ ls -il
total 8
2884381 drwxrwxr-x 5 user user 4096 Nov 6 11:46 Documents
2629156 -rw-rw-r-- 1 user user 0 Nov 13 14:09 file.txt
2884382 drwxrwxr-x 2 user user 4096 Nov 6 13:22 Pictures
$ ll
crw-rw-rw- 1 root tty 5, 0 Jan 6 13:45 /dev/tty
brw-rw---- 1 root disk 8, 0 Dec 21 14:12 /dev/sda
srw-rw-rw- 1 root root 0 Dec 21 14:13 /var/run/acpid.socket
prw------- 1 lance lance 0 Jan 5 17:44 /var/run/screen/S-lance/12138.ramereth
lrwxrwxrwx 1 root root 4 Nov 25 09:26 /var/run -> /run
$ stat /etc/services
File: `/etc/services'
Size: 19303 Blocks: 40 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 525111 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2015-01-07 08:22:43.768316048 -0800
Modify: 2012-05-03 09:01:30.934310452 -0700
Change: 2012-05-03 09:01:30.982310456 -0700
Birth: -
.jpg
, .txt
, .doc
# Tells you about the filetype using magic file data, not file extension
$ file $FILENAME
user@localhost ~ $ file file.txt
file.txt: ASCII text
user@localhost ~ $ file squirrel.jpg
squirrel.jpg: JPEG image data, JFIF standard 1.01
$ ls -l
drwxrwxr-x 5 user user 4096 Nov 6 11:46 Documents
-rw-rw-r-- 1 user user 0 Nov 13 14:09 file.txt
drwxrwxr-x 2 user user 4096 Nov 6 13:22 Pictures
+-----+--------+-------+
| rwx | Binary | Octal |
+-----+--------+-------+
| --- | 000 | 0 |
| --x | 001 | 1 |
| -w- | 010 | 2 |
| -wx | 011 | 3 |
| r-- | 100 | 4 |
| r-x | 101 | 5 |
| rw- | 110 | 6 |
| rwx | 111 | 7 |
+-----+--------+-------+
user & group
# Change the owner of myfile to "root".
$ chown root myfile
# Likewise, but also change its group to "staff".
$ chown root:staff myfile
# Change the owner of /mydir and subfiles to "root".
$ chown -hR root /mydir
# Make the group devops own the foo dir
$ chgrp -R devops /home/user/foo
drwxrwxr-x 5 user user 4096 Nov 6 11:46 Documents
-rw-rw-r-- 1 user user 0 Nov 13 14:09 file.txt
drwxrwxr-x 2 user user 4096 Nov 6 13:22 Pictures
---------- ------- ------- -------- ------------ -------------
| | | | | |
| | | | | File Name
| | | | +--- Modification Time
| | | +------------- Size (in bytes)
| | +----------------------- Group
| +-------------------------------- Owner
+---------------------------------------------- File Permissions
-
is a normal file
d
is a directory
b
is a block device
Take care of installation and removal of software
Core Functionality:
.deb
.rpm
Yum
Apt
RPM
Binary file format which includes metadata about the package and the application binaries as well.
Yum
RPM package manager used to query a central repository and resolve RPM package dependencies.
# Searching for a package
$ yum search tree
# Information about a package
$ yum info tree
# Installing a package
$ yum install tree
# Upgrade all packages to a newer version
$ yum upgrade
# Uninstalling a package
$ yum remove tree
# Cleaning the RPM database
$ yum clean all
Low level package management. No dependency checking or central repository.
# Install an RPM file
$ rpm -i tree-1.5.3-2.el6.x86_64.rpm
# Upgrade an RPM file
$ rpm -Uvh tree-1.5.3-3.el6.x86_64.rpm
# Uninstall an RPM package
$ rpm -e tree
# Querying the RPM database
$ rpm -qa tree
# Listing all files in an RPM package
$ rpm -ql tree
Readings: