Linux Fundamental
Linux Fundamental
Linux Fundamental
ISSUE1.0
www.huawei.com
Use
1.1 Overview
Friendly user interface : System kernel can be invoked friendly via user
interface (compared to Unix).
Debian Ubuntu
Linux Shell
Linux
Kernel
Practical
tools
Linux kernel: It is the core of the Linux operating system and provides the functions such as process
management, memory management, file system management, device control, and network management.
Utilities: The tools that are used by users for software development and system management,
including the GCC and KDE.
Linux shell: It is an interface that allows users to interact with the operating system. It is the general
term for command language, command interpreter, and programming language. By default, the Bourne
Again shell (BASH) is used. The BASH has many features. For example, it provides the functions such as
command completion, command edition, and command history table. Other common Linux shells are
CSH and KSH.
Virtual consoles can be added or deleted for login as required through the
configuration file /etc/inittab. One point, however, should be mentioned, that is,
you should skip virtual console 7 because this virtual console is used by X-
Window.
X Client Keyboard
X Client Display
X client: All applications running on the GUI are X clients. X clients include the window manager,
desktop environment, and file manager.
1) Window manager: provides the GUIs that the X server lacks.
Typical examples are Enlightenment, FVWM, fvwm95, and twm.
2) Desktop environment: provides a uniform operating platform for users to manage the system,
configure the system, and run applications. Main examples are Gnome desktop and KDE desktop.
3) File manager: manages files and subdirectories through menus, icons, and windows and provides
detailed file data. Examples are Nautilus and Konqueror.
X protocol: X protocol is the protocol used for information transmission between the X server and an X
client.
1.1 Overview
Manage users
Configure hardware
1.1 Overview
poweron
Init
Phase Phase /etc/inittab
2 4
RUNLEVEL ACTION
0 Power-off
1 Single-user mode
4 Free mode
5 Network multi-user mode with graphic interface
6 Restart
init 6
shutdown -r now
reboot
1.1 Overview
Use the terminal program to enter the traditional command line operation interface. The preceding figure is the
window that appears when you run the kosole terminal program. In the window, you can enter the shell command
to finish tasks quickly.
The method of starting a command line terminal varies with the desktop environment. To start a command line
terminal in the KDE desktop environment, choose system > Terminal on the system main menu or click the icon
on the desktop. To start a command line terminal in the Gnome desktop environment, choose More Applications…
> System > Gnome Terminal on the system main menu or click the icon on the desktop.
By default, Linux port 22 is open. In this case, you can log in to the system through the SSH protocol.
SSH is an encryption protocol that is recommended for remote management.
Before logging in to the system through Xmanager, you need to enable remote system
management. The recommended method is as follows: Enter yast on the textual interface and
then choose Network Services > Remote Administration > Allow Remote Administration.
HUAWEI TECHNOLOGIES CO., LTD. HUAWEI Confidential Page 26
Where to get help
Learn to use man and whatis commands. Remember that Linux is a case-
sensitive system.
For other Linux information resources, you are recommended to search on
www.google.com, www.linux.org, and www.linux.com.
What runlevels does the Linux operating system have? What are the
differences between these runlevels?
How to obtain the full spelling of a command when you know only the first few
letters of the command? How to get help when you do not know how to use a
command?
2.7 Others
− User Management
− Group Management
userdel Deletes a userdel -rf Deletes a user by force a userdel -rf db2inst
user username nd deletes the main direct
ory of the user.
usermod Modifies a usermod -d xxxx Modifies the main director usermod -d
user xxxx y of a user. /etc/db2inst db2inst
username
Information about users and groups is stored in the following three files:
/etc/passwd
/etc/shadow
/etc/group
You can modify the information through the GUI or command lines.
UID:
0–99: Used by the system.
100–499: Used by special system users (for example: services and
programs).
In the SLES 10, the UID of an ordinary user begins with 1000.
2.7 Others
The operating system uses a file system to make clear of the data structure and o
peration method of the files on a disk or partition. The Linux operating system sup
ports such file systems as EXT2 and EXT3.
EXT2 is a highly-scalable and high-performance file system. Before year 2000,
the file system of the Linux/GNU supports a file name as long as 256 bytes, a
maximum of 2048 GB (2 TB) size of a single file, and a maximum of 6384 GB
theory file system capacity.
EXT3 is a log file system that ensures the integrity of data in case of power fai
lure or other system failures. Compared to EXT2, EXT3 has a new log functio
n, that is, the function of recording metadata.
Other file systems are ReiserFs and XFS.These file systems support:
R: Read
d r w x r - x r - x W : Write
X : Execute
Read - 4
The default file right is set based on the value of umask (the
default value is 022).
The right of a new file is rw-r-r (644)
666 – 022 = rw-r-r
The default right of a new group is rwxr-xr-x.
a (all categories)
-f
Search :
-I
Find a file
-r
find / –name *.c
Grep matching
Insert
Search
i : before the cursor
/pattern : Search from the cursor to the
I : at the beginning of current cursor
end of the file.
a : after the cursor
?pattern : Search from the cursor to
A : at the end of current cursor
the beginning of the file.
o : insert a new line after the current line
Save and exit
O : insert a new line before the current line
:w Save the current file
Delete
:x Save the current file and exit
Deletion command x or dd: x allows you to
:q exit the vi editor
delete a character where the cursor is located
:q! not save the file and exit the
and dd allows you to delete the line where the
vi editor
cursor is located.
Use “ls -R” command to get the layer relation between files and folders.
Find and kill the process occupying the file you want to delete.
fuser filename
fuser –k filename
rsync
2.7 Others
create
edit
delete
mount -a
Uninstall a file
PV 、 VG 、 LV
PV
VG
LV
Extend the LV when the free space is used up if the configuration is suitable.
Add hard disks or LVs to a running system through the LVM. This, however,
requires hot-swappable hardware that can perform this operation.
Activate the striping mode that distributes the data of a logic volume in many
physical volumes. If these physical volumes reside on different disks, you
improve the read/write performance of the disk by activating the striping mode.
On this point, the LVM is similar to the RAIDO.
Back up running systems consistently by using the snapshot function (this is
especially suitable for servers)
Add a maximum of 256 LVs that can be either used by file systems or
databases as raw devices.
VG management
vgcreate -- Creates a volume group, for example, vgcreate -s 64M -v datavg1 /dev/sdd1
vgextend -- Extends a volume group.
vgreduce – Reduces a volume group.
vgdisplay -- Displays volume groups and logic volumes. Usually, the -v parameter is used.
LV management
lvcreate -- Creates a logic volume, for example, lvcreate -L 5120M -n db2lv2 datavg1
lvscan -- Scans logic volumes.
lvextend -- Extends a logic volume.
lvreduce – Reduces a logic volume.
2.7 Others
Modify hostname
Add a DNS server
route
default 192.168.0.1 - -
# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pg
Wake-on: g
Link detected: yes
2.7 Others
Run yast2, choose Software > Installation Source, and set the path where the
installation package is located.
Run yast2 and then choose Software > Software Management or run yast2
sw_single to start the software package management module.
Auto-arrange the dependencies between packages automatically.
name-version-release.architecture.rpm
The RPM library
rpm --rebuilddb
rpm -i ha.rpm
Install
rpm -e ha
delete
rpm -U ha.rpm
update
rpm -F ha.rpm
rpm -q
Queries what software packages have been installed.
rpm -q --changelog rpm_package
Displays detailed update information about software packages.
rpm -qa
Displays all installed software packages.
rpm -qi ha
Displays detailed information about the specific software package.
rpm -qf /opt/ha/bin/hapasswd
Queries what rpm package the command belongs to.
rpm -ql ha
Displays the RPM software package list.
rpm -qip package.rpm
Displays the content of the RPM software package (not install the RPM software
package).
rpm -V wget
S.5…T c /etc/wgetrc
Tag meanings
− S file size
− 5 MD5 checksum
− T modification time
− c configuration file
− L symbolic link is mismatched
− U user
− G group
− D the number of the master device or of the slave device is mismatched
Compiling and installing a source package usually involves three steps. This, however, varies
with the README or INSTALL document in the software package. Therefore, you are
recommended to view the README or INSTALL document in the software package before the
installation.
Configure the new software package
./configure [-options]
--prefix The prefix parameter allows you to set the basic subdirectory for installing the
software package. By default, the software package is installed in the lower-level
subdirectory of the /usr/local subdirectory. After the configuration, a special file "makefile"
is created, which is the cornerstone in the compiling phase.
Compile the new software package
Compiling a new software package is easy. You just need to run the make command and
then the make script will read all makefiles created by the configure program.
Install new software packages
After the compilation, run the following command to install the software package: make
install
2.7 Others
id:5:initdefault:
id:runlevel:action:process
ca::ctrlaltdel:/sbin/shutdown -r -t 4 now
Call the corresponding scripts in the /etc/init.d/rc (run level)
Service management
• User process
− Programs running on the terminal
• Daemon process
− Processes that are independent of the terminal
Process ID (PID)
ps
Displays user processes
ps aux
Displays all the running precesses
pstree
Displays the process content in tree structure
top
Views how the process resources are used
lsof
Views what files, directories, and sockets are opened by the running process
kill
Kills a thread according to the pid
killall
Kills a group of threads according to the name
ctrl + z
Stops a process
jobs
Displays processes
fg
2.7 Others
last Displays the last Displays the current user and last
current user and users who logged in to the
users who logged system previously.
in to the system
previously.
How to view the current users of the system and history operation records?
How to view the current network configuration of the system? How to obtain the
current network connection information? How to transfer data among hosts?
How to query how the disk is partitioned, how the disk partitions are mounted,
and how the space of the file system is used?
/etc/crontab
/etc/cron.hourly /etc/cron.weekly
/etc/cron.daily /etc/cron.monthly
User timer tasks
00 /5 * * * sent /usr/sales
The sent user runs the /usr/sales script every five hours.
Solutions to common crontab problems:
The crontab command is not running after it is set: Check whether the path of
the command is correct.
View the content of the /var/log/messages log.
top
dmesg Query the dmesg > /dir/file Query the boot dmesg >
boot message and save /tmp/dmesg.txt
message the query result to
the file /dir/file
uname -a
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/partitions
lspci
Display the first 10 processes that consume the most memory space
Display the first 10 processes in the system in the order that the processes are handled
Display the first 10 processes in the system that use the most or least memory actually
The possible reasons are as follows: one is that the user forgets the password and the other is
that the password is changed. No matter what reason causes the login failure, you can set a new
root password by doing as follows:
mount /dev/sda2 /mnt Run the mount /dev/sda2 /mnt command to mount the root file
system to /mnt (change the root disk name according to the actual situation)
Linux principals
Common commands
Common tips
http://www.chiark.greenend.org.uk/~sgtatham/putty/
SFTP client– WinSCP
http://winscp.net/eng/index.php
Hotline for post-sale support of Novell : 800-810-6500
Thank You
www.huawei.com
www.huawei.com