LinuxBasics

Differences between revisions 9 and 10
Revision 9 as of 2013-05-12 17:59:44
Size: 10562
Editor: adsl-65-8-201-196
Comment:
Revision 10 as of 2013-05-12 18:01:02
Size: 10541
Editor: adsl-65-8-201-196
Comment:
Deletions are marked like this. Additions are marked like this.
Line 65: Line 65:
= Linux Basics = = Linux File System =
Line 72: Line 72:

== Linux Filesystem ==

align="middle"

Introduction to the Command Line

This document provides a brief description of the Linux command line. It is not a complete guide, but rather an introduction to complement Kubuntu's graphical tools.

Under Linux there are GUI's (graphical user interfaces), where you can point and click and drap and hopefully get work done without first reading lots of documentation. The traditional Unix enviornment is a cli (command line interface), where you type commands to tell the computer what to do. This is faster and more powerfule, but requires finding out what the commands are.

  • All command names, file names, or paths to directories will be shown using a 'monospace font'.
  • All command names, file names, and or paths are case-sensitive. User, user, and USER are each different and distinct in Linux.
  • The commands should be issued from a command prompt within a terminal and will be shown as:

ls command

(Kubuntu's default terminal is called Konsole)

File and Directory Commands

pwd - print working directory

The 'pwd' command displays the directory where the user is currently located. Konsole also displays this information in both the tab and title bar of its window.

cd - change directory

The 'cd' command changes directories. When a terminal window is opened, it will be in the user's home directory. Moving around the file system requires the use of the cd command.

  • To navigate into the root directory, type: 'cd /'.
  • To navigate to the current user's home directory, type: 'cd' or 'cd ~'.
  • To navigate up one directory level, type: 'cd ..'.
  • To navigate up two directory levels, type: 'cd ../../'.
  • To navigate to the previous directory (go back), type: 'cd -'.

To navigate through multiple levels of directories at once, specify the full directory path. For example, type: 'cd /var/log' to go directly to the directory log subdirectory of var. For another example, typing: 'cd ~/Desktop' moves to the directory Desktop subdirectory inside the current user's home directory.

ls - list files

The 'ls' command outputs a list of the files in the current directory. For example, typing: 'ls ~' will display the files that are in the current user's home directory.

Used with the '-l' option, the 'ls' command outputs other information along with the filename, such as the permissions on the file, the file's owner, and more

Used with the '-al' options, the 'ls' command outputs the information associated with the '-l' option in addition to showing hidden files (the '-a' option)

touch - create empty file

mkdir - make directory

cp - copy files or directories

mv - move files or directories

rm - remove files or directories

System Information Commands

Linux File System

This document introduces the basics of a Linux system, which are useful for understanding Kubuntu under the graphic interface. This is sometimes referred to as the "cli", short for commandline interface.

For more on the Linux filesystem, see The Linux Directory Structure.

A filesystem is a method of storing and organizing files in all computer operating systems. In Linux most files are "regular files", except for 'directories', 'special files', 'links', 'sockets' and 'named pipes'. The most common filetypes that users interact with are regular files, directories, and links.

/bin

As you can see it holds important commands to system administrators (with full access privileges) and regular users (with limited access privileges). Command such as bash, ls (like we have learned), cp, and cat which are essential to the operation of a Linux system.

/boot

Contains the files required for the boot process. In the case of Kubuntu, it contains the files for the GRUB2 boot-loader, master boot records, map files, and the Linux kernel.

/dev

Location of special or device files. For example, /dev/sda0 is the first partition on the hard drive.

/etc

Contains all system-related configuration files used to control the operation of programs.

/home

Contains a home directory for each user on the system. A user's home directory can contain personal configuration files, documents, music, videos, and other user-defined directories and files.

/initrd-img

The initrd-img in / is a symlink to /boot/initrd.img-"kernel-version" the like the one in 13.04 is initrd.img-3.8.0-19-generic. This file is required for system startup.

/lib

Contains the kernel modules and shared library images needed to boot the system and run commands.

/lib32

Same as '/lib' above, but contains only the 32-bit versions.

/lib64

Same as '/lib' above, but contains only the 64-bit versions.

/lost+found

Contains the results of any recovery operations due to an improper shut-down of the system or a system crash.

/media

Contains the subdirectories which are used as mount points for removable media, such as CD's, DVD's, USB disks, or floppy disks.

/mnt

Generic mount point for filesystems or devices. In most cases, '/media' is where most devices will be auto-mounted.

/opt

Short for 'optional'. This directory is used for add-on packages that are typically installed manually by the user.

/proc

Virtual filesystem that contains runtime system information which is presented in a file-like structure.

/root

The home directory of the system administrator known as 'root'.

/sbin

Contains programs that are essential to the working of the sytem, such as 'fdisk', 'ifconfig', 'reboot', and 'shutdown'.

/selinux

A pseudo-filesystem containing the commands used by the kernel sub-system for the Security-Enhanced Linux feature.

/srv

Contains site-specific data which is served by the system.

/sys

Contains the Linux kernel, firmware, and system-related files.

/tmp

Contains files that are required temporarily. Many programs use this directory to create lock files and for temporary storage of data.

/usr

Contains the largest share of data on the system, including read-only user data, as well as files and programs, such as program binaries, documentation, libraries, header files, and more.

/var

Contains variable data, such as system log files, mail and printer spool directories, as well as transient and temporary files.

/vmlinuz

A symlink to a compressed executable of the Linux kernel.

Users and Groups

Since Linux is a true multi-user system, the principles of both 'users' and 'groups' are important to the internal operation of the system, and also to the day-to-day use of the system. The way Linux handles users and groups makes it one of the most secure operating systems.

Users

Physical Users are people who use the system physically. They have user ids which are usually unique, as well as group ids.

Logical Users are not tied to a person, but instead are tied to a system function that are used by applications to perform specific tasks. Daemons, mail, and news are examples of logical users.

Groups

Groups are logical expressions of organization. They tie users together and provide group-based, rather user-based, permissions. Common groups include 'admin', 'audio', 'mail'.

Permissions

In a multi-user environment, security of user and system data is important. Linux has three distinct classes:

  • r - read permission grants the ability to read a file.

  • w - write permission grants the ability to modify a file.

  • x - execute permission grants the ability to execute a file.

The list above shows the symbolic notation of each permission in italic text. Each permission also has an octal notation (is represented by digits from 0 to 7):

  • r - 4

  • w - 2

  • x - 1

Permissions Example

To view permissions, open a terminal by using Konsole and then type ls -l ~/

This will output a list of the directories and files in the current user's home directory. For example:

"drwxr-xr-x 6 aaron aaron 4096 May 1 17:30 Documents"

The first column, which contains drwxr-xr-x, can be interpreted as follows:

File Type

User Permissions

Group Permissions

Others Permissions

d - directory

rwx - read write execute

r-x - read and execute

r-x - read and execute

Octal to Symbolic Summary

Octal

Symbolic

Description

0

---

no permissions

1

--x

execute only

2

-w-

write only

3 (2+1)

-wx

write and execute

4

r--

read only

5 (4+1)

r-x

read and execute

6 (4+2)

rw-

read and write

7 (4+2+1)

rwx

read, write, and execute

Processes

Processes are instances of computer programs that are running. Next to files, processes are the second most important part of the Linux system.

- Viewing Processes in Kubuntu -

The keycombo 'Ctrl + Esc' starts KDE's System Activity dialog where processes can be viewed and killed.

Contents

  1. Welcome to Kubuntu

  2. About Kubuntu

  3. Kubuntu Basics

  4. Getting Involved

  5. The Web

  6. Multimedia

  7. Linux Basics


CategoryDocumentation

KubuntuDocs/RaringRingtail/LinuxBasics (last edited 2013-05-12 22:10:32 by adsl-65-8-201-196)