Debian; file system, superuser, commands, configuring and installing

Along this Debian class we will deal with the following. Debian file system, superuser, editing text files, executing commands in the shell, configuring, installing and uninstalling packages.

This post is part of a bigger Debian material that you can access here.

Debian File system, users and superusers; Introduction.

Debian GNU Linux uses the superuser paradigm. In computing, “the superuser is a special user account used for system administration. Depending on the operating system, the actual name of this account might be: root, administrator, admin or supervisor. In some cases the actual name is not significant, rather an authorization flag in the user’s profile determines if administrative functions can be performed. In operating systems which have the concept of a superuser, it is generally recommended that most application work be done using an ordinary account which does not have the ability to make system-wide changes.”

Taken from: http://en.wikipedia.org/wiki/Superuser on 2014-02-16

Debian Linux is of course a system with the superuser paradigm, by default the superuser name is root. But root might refer also to other parts of the system. Root is where every thing starts in Linux systems is like the alpha of the system. Is the “father

directory” (root directory represented by / ) in the file system. And root is also the “superuser”. to see the root directory you can execute the ls command from the fist class.
ls /
or
ls ­-la /
and to know if your current user is root you can use the whoami command also from the first class.
whoami
The root user is the privileged user of the system and is a lot more powerful than the Windows administrator; this user can even destroy the systems and it will not be even waned about it. The concept behind it is that this user should only be used when is strictly required. As you might already figure out you need to be extremely careful when working with this user. A lot of power comes with a lot of respectability. To continue with the root user now we will learn a command that helps to change your session to other users. ler say you are rafael and you want to change to miguel or to root. Well “su” is the command that you can use for that un debian and in most Linux systems. You can execute this command by it self:
su ­

Now it will prompt you for the root password and after you introduce it correctly it will change to the root user. Or if you want to change to a specific user you can use su, followed by the user name.

su class

To know the user you are in you can use the who am I command again.

whoami
As some of you might have noticed there is a small difference in the prompt between the root user and the non-privileged user. the non-privileged user appears in the shell with a $ and the root user with a # symbol. Check out this example:
[email protected]:~$ whoami
abel
[email protected]:~$ su
Password:
[email protected]:/home/abel# whoami
root
[email protected]:/home/abel# su abel
[email protected]:~$ whoami
abel
[email protected]:~$

The linux systems and Debian as one of them works like a cage for users. If you are abel and you execute su, then you login to root. But the session for abel does not end. After you execute su and change to root you can go back to your old session. To do that you just have to execute the command “exit” and it will take you back to the old user.

Before we continue with other content related to the file system and the super user. Let me introduce a few other commands and concepts.

System restart and shutdown; init run levels-command

  • init 0 – Shootsdown the computer. DEPRECATED in favour of “shutdown -h”
  • init 6 – Reboots the system.DEPRECATED in favour of shutdown e.g.: “shutdown -r +1”
Homework A:
  • What are the init run levels?
  • There are other init run levels from 1 to 5. What do they do?

Command to view current the network configuration; ifconfig.

“The ifconfig  is used to configure the kernel-resident network interfaces.  It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system  tuning  is needed.

If  no arguments are given, ifconfig displays the status of the currently active interfaces.  If a single interface argument is given, it displays the status of the given interface only; if a single -a  argument is  given,  it displays the status of all interfaces, even those that are down.  Otherwise, it configures an interface.”

Taken from ifconfig Debian official manual (man ifconfig)

Tor now we will use it just to view the network interface to view the interfaces configuration you just have to insert the command as root.

[email protected]:/home/abel# ifconfig 
eth0      Link encap:Ethernet  HWaddr 70:71:bc:b9:34:ad  
          inet addr:10.175.0.146  Bcast:10.175.1.255  Mask:255.255.254.0
          inet6 addr: fe80::7271:bcff:feb9:34ad/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29874506 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1161761 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5595877026 (5.2 GiB)  TX bytes:213607775 (203.7 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:333529 errors:0 dropped:0 overruns:0 frame:0
          TX packets:333529 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:123740836 (118.0 MiB)  TX bytes:123740836 (118.0 MiB)

[email protected]:/home/abel#

Feel free to research about this very useful command.

Remote connections using ssh protocol.

“OpenSSH is a FREE version of the SSH connectivity tools that technical users of the Internet rely on. Users of telnet, rlogin, and ftp may not realize that their password is transmitted across the Internet unencrypted, but it is. OpenSSH encrypts all traffic (including passwords) to effectively eliminate eavesdropping, connection hijacking, and other attacks. Additionally, OpenSSH  provides secure tunneling capabilities and several authentication methods, and supports all SSH protocol versions”
Taken from: http://www.openssh.com/ on 2014-02-16.
In the other hand, the Debian Official CD version comes with the ssh client installed by default. (that means you can use it to connect to ssh servers). And the ssh server can also be installed from repository. here is as example of how to connect through ssh.
[email protected]:~# ssh [email protected]
[email protected]'s password:
Linux khs01sw10 2.6.32­5­amd64 #1 SMP Mon Sep 23
22:14:43 UTC 2013 x86_64
(...)
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to
the extent
permitted by applicable law.
Last login: Mon Feb 17 15:50:11 2014 from 10.175.0.167
[email protected]:~#
Here in the first line you basically say that you are going to use ssh to connect with root at the host 10.175.0.1 (ssh [email protected]). If your connection is fine, the remote host has a ssh server running and you are allowed to connect from your IP address then you will be prompted for the password. Then insert the password and press enter and thats is it. You should login be logged in to the remote system. Only then you can execute any command on the remote system, like for instance init 6 to restart the remote system or also you can perform any other task there.

Mount command

As an additional homework lets call it B -I leave you the mount mount command
# mount
Research about how can we use the mount command?
File system Linux vs Windows

File system Linux vs Windows

Organization of the root directory and HDDs in Linux.

To organize the file system most modern Linux distribution like Debian use the File system Hierarchy Standard. That is an agreement between some authorities of the Free software, some companies and individuals to improve the systems efficiency and interoperability. As per Wikipedia:
The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix and Unix-like operating systems, maintained by the Linux Foundation. The current version is 2.3, announced on 29 January 2004.[1]
Taken from: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
on 2014-02-16.

You can find more information about it here and here. but for now to continue let me just mention the main directories that we will use along

FHS

FHS

This classes. Please feel free to user the ls command and also the CD command from class 1 to understand this structure.

  • /etc – Configuration files for most of the
  • softwares eg: ssh, network, dhcp, etc.
  • /home – users folder exept for the root user
  • eg: class, abel, pedro, miguel, etc.
  • /var -variable data eg: databases, caches,
  • logs.

And secondly we will also work with:

  • /media- Is the mounting point for removable media.
  • /mnt- mounting point for temporary mounted file systems.
  • /boot- boot loader static files.
  • /bin – essential user command binaries

Also we will work with the root user’s folder. So I will leave a homework, for you to research about it.

Homework C:

  • Where is the root user folder?

Now to continue with the class lets first learn hot to edit with nano.

Editing files with nano.

“nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. In contrast to Pico, nano is licensed under the GNU General Public License.”
Taken from: http://en.wikipedia.org/wiki/Nano_%28text_editor%29 on 2014-03-04
There are some other text editors like vi or vim both also for the shell and gedit or leafpad for the graphic interface. You can use the one you want or can. But in this classes I will assume you are using nano. Basics with nano:
  • To edit a file: $ nano /path/to/file.\
  • Nano internal commands:
    • CTRL + x: closes the file.
    • CTRL + o: saves.
    • CTRL + c: cursor position.
    • CTRL + k: cuts from nano.
    • CTRL + y: paste to nano from nano
    • CTRL + C cancels the current action if it’s not finished or says information about the cursor’s position.
Exersice 1: Create a text file called class1 in /home/class. Write some content and practice the commands from last slide.

The repository

“Commmonly refers to a storage location, often for safety or preservation. Many software publishers and other organizations

maintain servers on the Internet for this purpose, either free of charge or for a subscription fee. Repositories may be solely for particular programs, such as CPAN for the Perl programming language, or for an entire operating system. Operators of such repositories typically provide a package management system, tools intended to search for, install and otherwise manipulate software packages from the repositories. For example, many Linux distributions use Advanced Packaging Tool (APT), commonly found in Debian based distributions, or yum found in Red Hat based distributions. There are also multiple independent package management systems, such as pacman, used in Arch Linux and equo, found in Sabayon Linux.”
Taken from: http://en.wikipedia.org/wiki/Repository on 2014-02-16.
Now as the repository is formed by packages we have to define. What is a package?
“A package format is a type of archive containing files and additional metadata found on packages.While the archive file format itself is unchanged, package formats additionally specify the contents, such as requiring a manifest file or certain directory layout. The term is particularly used on Unix systems, and there are several formats available, both for Linux distributions and BSD systems, though the concept also includes pkg files on Mac OS X, MSI files on Windows, JAR files for Java, among others.”
Taken from: http://en.wikipedia.org/wiki/Linux_packages on 2014-03-04.
An other valid definition for package could be this one:
“In Linux distributions, a “package” refers to a compressed file archive containing all of the files that come with a particular application. The files are usually stored in the package according to their relative installation paths on your system. Most packages also contain installation instructions for the OS, as well as a list of any other packages that are dependencies (prerequisites required for installation.”
Taken from: http://www.internetblog.org.uk/post/1520/what-is-a-linux-package/ 2014-03-04.

Debian Package Management

apt-get – package manager
aptitude – higher level package manager.
  • aptitude install ssh
  • aptitude install mc
Homework C –
What us the diference between:
  • aptitude update
  • aptitude install
  • aptitude upgrade
How do you remove a packege?
How can you search for a package?
And that is it for today. On the next class we will discus about the package manager and we will install a DHCP server. be ready for it.

 

 

Posted in Debian, Linux, Networking
2 comments on “Debian; file system, superuser, commands, configuring and installing
  1. Motsumi says:

    Good lessons!

  2. abel says:

    Thank you Motsumi;
    I will try to continue improving them… actually this is kind of my main task this days.
    Regards
    Abel

Leave a Reply

Your email address will not be published. Required fields are marked *

*