0% found this document useful (0 votes)
3 views

Debian Reference

Uploaded by

Tony De La Rocha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Debian Reference

Uploaded by

Tony De La Rocha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

<HTML><HEAD><TITLE>DEBIAN REFERENCE</TITLE></HEAD>

<BODY BGCOLOR=#FFFFFF><H2>DEBIAN REFERENCE .... </H2><PRE>


<HR>

1.-
_______________
CONSOLE BASICS

THE SHELL PROMPT


get to a login prompt by Ctrl-Alt-F1
return to the GUI environment via Alt-F7
To dispay system information run "uname -snrvm"

THE ROOT ACCOUNT (superuser)


- Read, write, and remove any files on the system irrespective of their file
permissions
- Set file ownership and permissions of any files on the system
- Set the password of any non-privileged users on the system
- Login to any accounts without their passwords

THE ROOT SHELL PROMPT


- Type root at the character based login prompt.
- Click "Applications" > "Accessories" > "Root Terminal", under the GNOME Desktop
environment.
- Type "su -l" from any user shell prompt.
- Type "su" from any user shell prompt.

VIRTUAL CONSOLES
there are six switchable VT100-like character consoles
switch between the virtual consoles by pressing the Left-Alt-key and one of the F1
— F6 keys simultaneously.
Each character console allows independent login to the account and offers a
multiuser environment.
gain access to the character console 1 by pressing Ctrl-Alt-F1
get back to the X Window System, normally running on the virtual console 7, by
pressing Alt-F7.
alternatively change to another virtual console, e.g. to the console 1, from the
commandline. <mark><b># chvt 1</mark></b>

HOW TO LEAVE THE COMMAND PROMPT


to close the shell activity type Ctrl-D -or- exit.

HOW TO SHUTDOWN THE SYSTEM


Like any other modern OS where the file operation involves caching data in memory
for improved performance, the Debian
system needs the proper shutdown procedure before power can safely be turned off.
This is to maintain the integrity of files,
by forcing all changes in memory to be written to disk.

Shutdown the system under the normal multiuser mode. <mark><b># shutdown -h
now</mark></b>
Alternatively, you may type Ctrl-Alt-Delete

RECOVERING A SANE CONSOLE


The "<mark><b>reset</mark></b>" command, resets the console session to defaults.
The "<mark><b>clean</mark></b>" command, clears up the screnn.

ADDITIONAL PACKAGES
Install packages by <mark><b># aptitude install package_name</mark></b>

CREATE/DELETE USER ACCOUNTS


CREATE a user account. <mark><b># adduser fish</mark></b>
DELETE a user account and its home directory. <mark><b># deluser --remove-home
fish</mark></b>

SUDO CONFIGURATION
To let the non-privileged user gain administrative privilege. <mark><b># echo
"penguin ALL=(ALL) ALL" >> /etc/sudoers</mark></B>

Give administrative privilege to a non-privileged user


1.- from root
2.- adduser [username]
3.- echo "[username ALL=(ALL) ALL" >> /etc/sudoers
4.- login as the new user (to change: su -l [username])
5.- sudo [command]

UNIX-LIKE FILESYSTEM
Files are organized into directories. All files and directories are arranged in one
big tree rooted at "/".
files and directories can be spread out over several devices.
"<mark><b>mount</mark></b>" attach a device filesystem to the big file tree.
Conversely, "<mark><b>umount</mark></b>" detaches it again.

UNIX FILE BASICS


- Filenames are case sensitive.
- The root directory means root of the filesystem referred as simply "/".
- Every directory has a name which can contain any letters or symbols except "/".
- Each file or directory is designated by a fully-qualified filename, absolute
filename, or path
- All fully-qualified filenames begin with the "/" directory, and there’s a "/"
between each directory or file in the filename.
The first "/" is the top level directory, and the other "/"’s separate successive
subdirectories, until we reach the last entry
which is the name of the actual file.
- the directory "<mark><b>../</mark></b>" refers to the parent directory
- directory entries do exist that refer to physical devices as a part of the normal
filesystem

FILESYSTEM HIERARCHY STANDARD


"<mark><b>/usr/share/doc/debian-policy/fhs/fhs-2.3.txt.gz</mark></b>" and
<mark><b>hier(7)</mark></b>

DIRECTORY USAGE OF THE DIRECTORY


/ the root directory
/etc/ system wide configuration files
/var/log/ system log files
/home/ all the home directories for all non-privileged users
FILESYSTEM INTERNALS
The FILESYSTEM is the logical entity where physical data on hard disks and other
storage devices reside.
The interaction with the hardware devices is represented
"<mark><b>/dev/</mark></b>".
The INODE is a data structure that describes associated attributes as: owner,
group, time last accessed, etc.

FILESYSTEM PERMISSIONS
USERS...
- The USER who owns the file (u)
- Other users in the GROUP which the file belongs to (g)
- All OTHER users (o) also referred to as "world" and "everyone"

FILE...
- The READ (r) permission allows owner to examine contents of the file.
- The WRITE (w) permission allows owner to modify the file.
- The EXECUTE (x) permission allows owner to run the file as a command.

DIRECTORY...
- The READ (r) permission allows owner to list contents of the directory.
- The WRITE (w) permission allows owner to add or remove files in the directory.
- The EXECUTE (x) permission allows owner to access files in the directory

LIST OF THE FIRST CHARACTER OF "<mark><b>ls -l</mark></b>" OUTPUT


CHARACTER MEANING
- normal file
d directory
l symlink
c character device node
b block device node
p named pipe
s socket

"<mark><b>chown</mark></b>" is used from the root account to change the owner of


the file.
"<mark><b>chgrp</mark></b>" is used from the file's owner or root account to change
the group of the file.
"<mark><b>chmod</mark></b>" is used from the file's owner or root account to change
file and directory access permissions.

SPECIAL PERMISSION BITS.


- The SET USER ID bit (s or S instead of user's x)
Setting set user ID on an executable file allows a user to execute the executable
file with the owner ID.

- The SET GROUP ID bit (s or S instead of group's x)


Setting set group ID on an executable file allows a user to execute the executable
file with the group ID of the file.
Setting set group ID on a directory mades all files created in the directory to
belong to the group of the directory.

- The STICKY bit (t or T instead of other's x)


Setting the sticky bit on a directory prevents a file in the directory from being
removed by a user who is not the owner of the file.

There is an alternative numeric mode to describe file permissions with


"<mark><b>chmod</mark></b>".
owner group other
r w x r w x r w x
1 1 1 1 1 1 1 1 1
- - - - - - - - -
7 7 7

CONTROL OF PERMISSIONS FOR NEWLY CREATED FILES: "<mark><b>umask</mark></b>"


Considering that: (because 0666 & ~022 = 0644; i.e., rw-r--r--).
tony@debian:~$ umask -S
u=rwx,g=rx,o=rx
tony@debian:~$ umask -p
umask 0022
tony@debian:~$ touch myfile
tony@debian:~$ ls -la | grep myfile
-rw-r--r-- 1 tony tony 0 Jun 20 18:47 myfile

PERMISSIONS FOR GROUPS OF USERS (GROUP)


In order to make group permissions to be applied to a particular user, that user
needs to be made a member of the group using "<mark><b>sudo vigr</mark></b>"

TIMESTAMPS
TYPE MEANING
mtime the file modification time (ls -l)
ctime the file status change time (ls -lc)
atime the last file access time (ls -lu)

- Overwriting a file changes all of the mtime, ctime, and atime attributes of the
file.
- Changing ownership or permission of a file changes the ctime and atime attributes
of the file.
- Reading a file changes the atime of the file.

LINKS
HARD LINK
Duplicate an existing file using another name
The hardlink can be made within the same filesystem and shares the same inode
number which the <mark><b>-i</mark></b>" reveals
An INODE is a data structure used to represent a filesystem object.

EX... "ln MyOriginalFile DuplicatedCopyOfMyOriginalFile"


tony@debian:~$ vi MyOriginalFile
tony@debian:~$ cat MyOriginalFile
This is the original file
tony@debian:~$ ln MyOriginalFile DuplicatedCopyOfMyOriginalFile
tony@debian:~$ cat DuplicatedCopyOfMyOriginalFile
This is the original file
tony@debian:~$
tony@debian:~$ ls -li MyOriginalFile
4468094 -rw-r--r-- 2 tony tony 26 Jun 20 19:19 MyOriginalFile
tony@debian:~$
tony@debian:~$ ls -li DuplicatedCopyOfMyOriginalFile
4468094 -rw-r--r-- 2 tony tony 26 Jun 20 19:19 DuplicatedCopyOfMyOriginalFile
SYMBOLIC LINK OR SYMLINK
Special file that points to another file by name.
The symlink always has nominal file access permissions of "rwxrwxrwx", as shown in
the above example,
with the effective access permissions dictated by permissions of the file that it
points to.

EX... "ln -s MyOriginalFile PointerToMyOriginalFile"


tony@debian:~$ ln -s MyOriginalFile PointerToMyOriginalFile
tony@debian:~$
tony@debian:~$ cat PointerToMyOriginalFile
This is the original file
tony@debian:~$
tony@debian:~$ ls -li PointerToMyOriginalFile
4468029 lrwxrwxrwx 1 tony tony 14 Jun 20 19:20 PointerToMyOriginalFile ->
MyOriginalFile

________
SOCKETS
Sockets are used extensively by all the Internet communication, databases, and the
operating system itself.
Allows processes to exchange information even between different computers.
"<mark><b>netstat -an</mark></b>" provides a very useful overview of sockets that
are open on a given system.

______________
DEVICE FILES
Device files refer to physical or virtual devices: hard disk, video card, screen,
keyboard, etc...
EX... "<mark><b>/dev/console</mark></b>".

TYPES OF DEVICE FILES.


CHARACTER DEVICE
Accessed one character at a time (1 character = 1 byte)
EX... keyboard device, serial port, . . .

BLOCK DEVICE
Accessed in larger units called blocks (1 block > 1 byte)
EX... hard disk, . . .

___________________
procfs and sysfs
The procfs and sysfs mounted on "/proc" and "/sys" are the pseudo-filesystem and
expose internal data structures of the kernel to the userspace.
"<mark><b>/proc</mark></b>" contains one subdirectory for each process running on
the system, which is named after the process ID (PID).
"<mark><b>/proc/sys/</mark></b>" contain interface to change certain kernel
parameters at run time.

________________________
MIDNIGHT COMMANDER (MC)
Use the "<mark><b>mc</mark></b>" command to explore the Debian system.

KEY KEY BINDING


F1 help menu
F3 internal file viewer
F4 internal editor
F9 activate pull down menu
F10 exit Midnight Commander
Tab move between two windows
Insert or Ctrl-T mark file for a multiple-file operation such as copy
Del delete file (be careful---set MC to safe delete mode)
Cursor keys self-explanatory

..........
THE INTERNAL EDITOR IN MC
To edit a file from mc run....
"<mark><b>mc -e filename_to_edit</mark></b>"
"<mark><b>mcedit filename_to_edit</mark></b>"

..........
THE INTERNAL VIEWER IN MC
To view and search a file content...
"<mark><b>mc -v path/to/filename_to_view</mark></b>"
"<mark><b>mcview path/to/filename_to_view</mark></b>"

..........
AUTO-START FEATURES OF MC
Press Enter on a file, and the appropriate program handles the content of the file
Viewable files should not be set as executable. Change their status using chmod(1).

..........
FTP VIRTUAL FILESYSTEM OF MC
MC can be used to access files over the Internet using FTP.
Go to the menu by pressing F9, then type "P" to activate the FTP.
virtual filesystem. Enter a URL in the form "username:[email protected]"

_______________________________________
THE BASIC UNIX-LIKE WORK ENVIRONMENT

..........
THE LOGIN SHELL
Select the login shell with <mark><b>chsh(1)</mark></b>

PACKAGES
bash
tcsh
dash
zsh
pdksh
csh
sash
ksh
rc
posh

..........
SPECIAL KEY STROKES
On a normal Linux character console, only the left-hand Ctrl and Alt keys work as
expected.

LIST OF KEY BINDINGS FOR BASH


KEY DESCRIPTION OF KEY BINDING
Ctrl-U erase line before cursor
Ctrl-H erase a character before cursor
Ctrl-D terminate input (exit shell if you are using shell)
Ctrl-C terminate a running program
Ctrl-Z temporarily stop program by moving it to the background job
Ctrl-S halt output to screen
Ctrl-Q reactivate output to screen
Ctrl-Alt-Del reboot/halt the system, see inittab(5)
Up-arrow start command history search under bash
Ctrl-R start incremental command history search under bash
Tab complete input of the filename to the command line under bash
Ctrl-V Tab input Tab without expansion to the command line under bash

LIST OF UNIX STYLE MOUSE OPERATIONS


ACTION RESPONSE
Left-click-and-drag mouse select and copy to the clipboard
Left-click select the start of selection
Right-click select the end of selection and copy to the clipboard
Middle-click paste clipboard at the cursor

.....
THE PAGER
<mark><b>less(1)</mark></b> is the enhanced pager.
Hit "h" for help. It can do much more than more(1)

.....
RECORDING THE SHELL ACTIVITIES
The output of the shell command may roll off your screen and may be lost forever.
It is good practice to log shell activities into a file for you to review them
later. Especially when performing system administration tasks.
The basic method of recording the shell activity is to run it under
<mark><b>script(1)</mark></b>.
EX...
<mark><b>$ script</mark></b>
<mark><b>Script started, file is typescript</mark></b>
Do whatever shell commands under script.
Press Ctrl-D to exit script.
<mark><b>$ vim typescript</mark></b> (to see the recorded file content)

.....
BASIC UNIX COMMANDS
</BODY></HTML>

You might also like