Anda di halaman 1dari 12

44

Basic information about the


system console

45

Linux console
Console is wrongly regarded as something highly complicated,
beginners often think that you can't use Linux without a
console
It's not necessary in everyday work
However, it facilitates some administrative tasks
Most graphical applications are actually window interfaces for
commands available from the terminal level
Using the console, the user can often get more information in
case of an error
The console also enables grouping or automation of a certain
number of tasks and facilitates some operations

46

Bash - what is it?

Bash is a system shell for Linux


It's one of the most popular unix system shells
It originates from the sh shell
It was created in 1987, currently it's the main
shell for the majority of Linux systems
Bash is also a very good script language, used
to efficiently manage the system

47

Script - what is it?


It's nothing more than a text file with subsequent
instructions to be performed during the script
launch
These commands can be internal shell commands,
other scripts or binary programs
The system shell translates these commands to
calls which can be understood by the operating
system
They are the same as .bat files encountered
sometimes in Windows systems

48

Useful hotkeys
Ctrl+R search in the history of executed commands
Shift+PageUp (PageDown) scrolling the command
screen
Up and down arrow scrolling the history of recent
commands
Ctrl+Shift+T open a new tab in the terminal available in
KDE and Gnome
Ctrl+D closing the console/logout; the same effect can
be obtained by entering the exit command

49

Basic commands

cd <directory name> - changing the directory to the chosen one


cd /home/boing absolute path
cd my/files relative path
cd .. going to the parent directory

~ - designates the user home directory


rm removing files and directories
Removing a directory requires adding an -r switch
An -f switch designates "force", i.e. the approval for everything
Watch out for commands rm -rf / erasing the entire system!

mkdir <path> creating the last directory in the path


-p switch creating all directories in the path which don't exist yet

50

Basic commands (continued)


echo <text> displaying the entered text as a
parameter
cat <file> displaying the file contents
less <file> - browsing the file contents with the
possibility of moving forwards and backwards
/ search in the text
q end of browsing

tail <file> - browsing the file "backwards"


tail -f <file> - previewing changes in files in real time

51

Basic commands (continued)


ls browsing files and directories
ls l with details
ls a shows hidden files and directories

ps list of active processes


ps aux processes of all users

top a preview of the existing processes with automatic


sorting with respect to the action time, occupied memory or
CPU
wget getting files from the Internet (similarly as via a
browser)
eject ejecting a CD

52

Basic commands (continued)


su switching to another user
su switching to root without processing the settings
su /su root switching to root with the processing
settings
su user switching to the user named "user"

sudo executing a command as an administrator, it


enables safe system management during everyday work
kill a command which closes a hanging program
kill [-9] <pid>

53

System variables

System variables are certain labels understood by the system in specific situations
For instance, when entering a command, the system should know where to find this
command. This information is stored in the PATH variable
We can create variables at any time, assigning them a value

In order to refer to the variable, precede its name with the character $

VARIABLE=contents
echo VARIABLE
echo $VARIABLE

Two basic variables are PATH (search path) and HOME (a path to the user's home
directory)
System variables are deleted once the console window is closed!

54

Editing files in the console


In Linux there are many text processors
The most common are:

Vi
Emacs
Nano
Mcedit (part of the mc/midnight commander set)

Both mcedit and nano are simple and clear, their basic
commands are written on the screen
Mc is particularly easy to use because it has similar buttons as
the ones in Total Commander
Emacs is pretty complex and not that easy to handle

55

Vi/Vim
Vi is the most popular and complex editor, which also
makes it pretty hard to use (however, it's available
anywhere and anytime)
Basic commands:

insert entering the editing mode


esc leaving the editing mode
:w saving the file
:q closing the application
:q! closing the application without saving
:wq closing with saving

Anda mungkin juga menyukai