You are here

Training Day 1 - Linux +

The first day of training is over and I thought I would attempt to recap what was learnt. The following information is some copy and pasting from various sources online:

Linux Installation and Usage

Kernel Definition:
An operating system is merely a collection of software that allows you to use your computer hardware in a meaningful fashion. Every operating system has a core component, which loads all other components and serves to centrally control the activities of the computer. This component is known as the kernel, and in Linux is simply a file usually called “vmlinuz”, which is located on the hard drive and loaded when you first turn on your computer.

When a user logs into a terminal, they receives a user interface called a shell which then accepts input and passes it to the kernel for processing.

*Note*
In Linux, the BASH shell (Bourne Again Shell) is the default.

Page 143/648 (Linux+ ebook.pdf)
Using the uname command with the -a option will display the node name, kernel name, kernel version, kernel release, machine info, processor, hardware platform and the OS name.

[Expert@cpmodule]#uname -a
Linux cpmodule 2.4.21-21cp #1 Sun Feb 11 15:56:58 IST 2007 i686 i686 i386 GNU/Linux

Command Recap:

ls – directory listing
date – show the current date and time
ls -al – formatted listing with hidden files
cd [dir] - change directory to dir
uptime – show current uptime
cd – change to home
w – display who is online
pwd – show current directory
whoami – who you are logged in as
mkdir [dir] – create a directory dir
rm file – delete file
uname -a – show kernel information
rm -r dir – delete directory dir
cat > file – places standard input into file
cat /proc/cpuinfo – cpu information
cat /proc/meminfo – memory information
rm -f file – force remove file
rm -rf dir – force remove directory dir *
man command – show the manual for command
cp file1 file2 – copy file1 to file2
cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it doesn't exist
df – show disk usage
du – show directory space usage
free – show memory and swap usage
mv file1 file2 – rename or move file1 to file2 if file2 is an existing directory, moves file1 into directory file2
whereis [app] – show possible locations of app
which [app] – show which app will be run by default
ln -s file link – create symbolic link link to file
tar cf file.tar files – create a tar named file.tar containing files
tar czf file.tar.gz files – create a tar with Gzip compression
tar xzf file.tar.gz – extract a tar using Gzip
tar xf file.tar – extract the files from file.tar
more file – output the contents of file
head file – output the first 10 lines of file
tail file – output the last 10 lines of file
tail -f file – output the contents of file as it grows, starting with the last 10 lines
touch file – create or update file

Permissions:
chmod [octal] [file] – change the permissions of file to octal, which can be found separately for user, group, and world by adding:
4–read(r)
2 – write (w)
1 – execute (x)

Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world

You can use wildcards with any command that accepts file names as arguments.

*
zero or more characters

?
exactly one character

[abcde]
exactly one character listed

[a-e]
exactly one character in the given range

[!abcde]
any character that is not listed

[!a-e]
any character that is not in the given range

{debian,linux}
exactly one entire word in the options given

For example, the following removes every file from the current directory:

$ rm *

The following command moves all the HTML files, that have the word "linux" in their names, from the working directory into a directory named dir1:
$ mv *linux*.html dir1

The following displays all files that begin with d and end with .txt:

$ less d*.txt

The following command removes all files whose names begin with junk., followed by exactly three characters:

$ rm junk.???

With this command you list all files or directories whose names begin with hda, followed by exactly one numeral:

$ ls hda[0-9]

This lists all files or directories beginning with hda, followed by exactly two numerals:
$
ls hda[0-9][0-9]

The following lists all files or directories whose name starts with either hd or sd, followed by any single character between a and c:

$ ls {hd,sd}[a-c]

This command copies all files, that begin with an uppercase letter, to directory dir2:

$ cp [A-Z]* dir2

This deletes all files that don't end with c, e, h or g:

$ rm *[!cehg]