Enter the Linux

Introduction to Linux

Linux is the name usually given to any Unix-like computer operating system that uses the Linux kernel. Linux is one of the most prominent examples of free software and open source development: typically all underlying source code can be freely modified, used, and redistributed by anyone.

The name “Linux” comes from the Linux kernel started in 1991 by Linus Torvalds. The system’s utilities and libraries usually come from the GNU operating system, announced in 1983 by Richard Stallman. The GNU contribution is the basis for the alternative name GNU/Linux.

Predominantly known for its use in servers, Linux is supported by corporations such as Dell, Hewlett-Packard, IBM, Novell, Oracle Corporation, Red Hat, and Sun Microsystems. It is used as an operating system for a wide variety of computer hardware, including desktop computers, supercomputers, and embedded devices such as E-book readers, video game systems (PlayStation 2, PlayStation 3 and XBox, mobile phones and routers.

· You might get questions about server ssh keys
· Those keys are used for securely identifying the server
· If it is the first time you connect to the specific server: accept the key
· The key gets stored locally on your PC

– General Linux remarks

· Path separator on Linux is: / (slash, or forward slash)
· Linux is case-sensitive: always use the correct case:
· aFileName is not the same as afilename
· Text files on Linux have a different line ending than text files on windows (Linux: n, Windows: rn)
· This can cause problems when transferring files:
· Transfer text files as text files, line endings are automatically corrected
· Otherwise you get weird characters in your files (^M) or the whole file is on one line
· Transfer non-text (binary) files as binary files
· Otherwise the files may get corrupted!
· There is no Recycle Bin, think twice before you’ll perform delete action!
· Everything that its name starts with a . (dot) is a hidden file/directory

• The tar command lets you archiving files and directories into a single file, it does not compress them

tar –cvf logs.tar *.log

Archive all log files into logs.tar (no compression yet)

tar –xvf logs.tar

Unarchive all files from logs.tar

• The gzip command compresses a file

gzip logs.tar

Compresses logs.tar to logs.tar.gz (removing logs.tar)

gunzip logs.tar.gz

Decompresses logs.tar.gz to logs.tar (removing logs.tar.gz)

• Combined (you could combine tar with gzip in one command)

tar –cvzf logs.tar.gz *.log

Packs and compresses all log files into logs.tar.gz

tar –xvzf logs.tar.gz

Decompresses and unpacks all files from logs.tar.gz

File viewing commands

• less – shows the content on your screen and allows you to page through it
• grep – searches a file for a string
• tail – shows the end of a file
• wc – counts words or lines in a file
• file – displays the type of a file
• cat – dumps the contents of a file on your screen

Command: less

• The less command shows the content on your screen and allows you to page through it

Searches for the string ‘error’ in all files ending with .log in the current directory

Command: tail

• The tail command shows the last part of a file

tail -n 50 logfile.log

Shows the last 50 lines of the file ‘logfile.log’

tail -f logfile.log

Follows the end of ‘logfile.log’, every line that is appended by another process is shown on your screen (very handy tracking files in real time)

Command: wc

• The wc command counts words or lines in a file

wc -l logfile.log – Count the number of lines in the file ‘logfile.log’

Command: ps

• The ps command shows a snapshot of current processes

• For continuous information: use top

ps

Show all processes for the current user at the current terminal

ps -e

Show all processes on the system PID, TTY, TIME and CMD

ps -ef

Show all processes on the system with extended info UID, PID, PPID, C, STIME, TTY, TIME and CMD

ps -efH

Show all processes on the system with extended info as a tree UID, PID, PPID, C, STIME, TTY, TIME and CMD

ps auxf

it’s also cool display

– UID The user id
– PID The process id
– PPID The parent process id
– C Percentage CPU usage
– STIME Starting time of the process. If the elapsed time is > 24 hours, the starting date
– TTY The terminal that started the process
– TIME The CPU time used
– CMD The executing command

• ctrl+c cancels a running program (most of the time)
• ctrl+d ends a session (as does the exit command)
• screen: (must be installed) Use multiple screens, and keep sessions alive between (dis)connects

• man : Asks for the manual page of a command / program e.g. man cp
• which : find out the path of the command
• tab key auto completion

For instance:
taping “cd /home/userone” could be written much faster with help of tab key functionality:

cd /ho[press tab]/use[press tab] – observe that the right existing path will be auto filled up – very handy! use it!

Short Description of the Linux file structure

Filesystems

Description

root “/”

Basic operating system and maintenance tools. The content of this file system should be sufficient to start up the system and perform emergency maintenance and repairs if they were necessary.

The parts of the root file system are:

/bin

–executables (binaries) needed during bootup that might be used by normal users.

/sbin

–executables (system binaries) not intended for use by general users (users may still use them, but this directory is not on their PATH).

/etc

–system-wide configuration files for your operating system.

/root

–the home directory of the system administrator (called super-user or root).

/dev

–device files. Devices appear on Linux as files so that hardware is abstracted and it is easy to write to them or read from them.

/mnt

–mount points for removable media (floppy, cdrom, zip drive), partitions of other operating systems (e.g. MS Windows), network shares, and anything else that is mounted on the file system temporarily. It normally contains a separate subdirectory for each mounting share. The contents of these drives/shares appear in these subdirectories–there are no drive letters on Linux.

/lib

–shared libraries for programs that reside on the root filesystem and kernel modules.

/boot

–files used by the bootstrap loader (LILO or GRUB), the thing that loads first when the computer is booted and perhaps gives you the option of which operating system to boot, if you have more than one OS on your computer). It typically also contains the Linux kernel (compressed, file vmlinuz), but this can be stored somewhere else, only if LILO/GRUB is configured to know where it is.

/opt

–optional large applications, for example kde under RedHat 5.2 (under RedHat 6.0, kde is distributed as any other X-windows distribution, main executables are in the /usr/bin directory).

/tmp

–temporary files. This directory may clean up automatically.

/lost+found

–files recovered during the filesystem repair.

/usr

All commands, libraries, documentation, and other files that do not change during normal operation. This will also contain major applications that come with your Linux distribution, for example Netscape.

/var

/home

User files (users’ own settings, customization files, documents, data, mail, caches, etc). The contents of this directory should be preserved on an operating system upgrade. ~(tilde) Is the alias for your home directory ex. cd ~ or cd will lead you to your home directory instead cd /home/your_user

/proc

Entirely illusionary files. They do not really exist on the disk and do not take up any space there (although ls -l will show their size). When viewing them, you really access information stored in the memory. It is used to access information about the system.

PuTTY Connection Manager – seems that project has been abandoned. But you could find some old versions on th einternet here

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.