Wednesday, August 29, 2007

Octave - 1

Begin: octave
Interrupt: Ctrl + C
Exit: quit or exit
suspend: Ctrl + Z
EXAMPLES:

Matrices
octave:1> A = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ]  (Create matrix to store for later. printout)
octave:2> B = rand (3, 2); (Create matrix 3 rows 2 columns, random vars, no printout)
octave:3> B (Display B)

octave:4> 2 * A (Matrix A times scalar a)
octave:5> A * B (Matrix matrix multiply)
octave:6> A' * A (transpose (A) * A)

octave:7> A \ b (solve Ax = b)



Basic Linux Commands - 4

Command Function
ls Short listing of directory contents
cd [dirname] Change directory to [dirname]
cd .. Change directory and go back a level
cd Change back to your home directory
cd $\sim$ Change back to your home directory
cp [oldfile] [newfile] Copy a file
mv [oldpath/oldfile] [newpath/newfile] Move or rename a file
rm [file_to_delete] Delete a file (files are unrecoverable)
gzip [file_to_compress] Compress a file using gzip
gunzip [file_to_uncompress] Uncompress a gzipped file
mkdir [new_dir_name] Create a directory in the current directory
rmdir [dir_to_delete] Remove a directory (if it is empty)
man [command] Get the manual pages for [command]

Exercises on basic Unix (Linux) commands

1.1 Introduction

Hints:

  • green texts are comments/explanations,
  • gray text is what cames on the screen,
  • red text are the commands you have to type in (and [xyz] means to type the "xyz" key)

System configuration

shell bash;
different accounts ;
User needs to have personal groups (user radio belongs to group students, ..);
su;
virtual console


1.2 Access to the system and logout

Let's start with something wrong.

login: redio[Enter]

Even if the account doesn't exist you'll be asked for a password

Password: radio2001[Enter]

Login incorrect


Let's start again

login: radio[Enter]

Password: 2001[Enter]

Last login: Sun Nov 11 10:45:11 on tty1

You get information about your last access

The prompt shell means the system is ready to receive your commands.

$


1.2.1 Switching account

logging out and then logging in with a different account
using su.

$ su root[Enter]

Password: smr1301[Enter]

If it is the right password you get identity and the rights of the typed user.


1.2.2 Virtual Consoles

[Alt+Fn] (where n is in the range 1..6).

You can start another login session on a different console

1.2.3 Who am I?

When you have more then one account may be necessary to check which account you are using.

$ whoami[Enter]

root

whoami let you know under which identity you are working on.

$ logname[Enter]

radio

logname allows you to know what account you used when you first entered in the system (login).

1.2.4 Ending a session

Just need to end the shell, that is the program that shows the prompt.

$ whoami[Enter]

root

$ exit[Enter]

In case we had used su

$ whoami[Enter]

radio

This exit closes last shell, and logs the user out of the system.

$ exit[Enter]

login:



1.2.5 Shutting down

login: root[Enter]

Password: smr1301[Enter]

# shutdown -h now[Enter]

System is going down NOW!!

...

System halted

When this happens it is possible to reboot the system.

---------

You can use su to become root and shutdown the system.

$ su[Enter]

Password: smr1301[Enter]

# shutdown -h now[Enter]


1.3 Password management

1.3.1 User root changes password to regular user

# passwd radio[Enter]

New UNIX password: 123[Enter]

The password is too short, the system advises you but it doesn't stop you from using it.

BAD PASSWORD: it's a WAY too short

Retype new UNIX password: 123[Enter]

passwd: all authentication tokens updated successfully


1.3.2 Regular user changes its password

$ passwd[Enter]

You'll be asked for the old password.

Changing password for radio

(current) UNIX password: 123[Enter]

New UNIX password: elpoep[Enter]

BAD PASSWORD: it is based on a (reversed) dictionary word

passwd: Authentication token manipulation error

$ passwd[Enter]

Changing password for radio

(current) UNIX password: 123[Enter]

New UNIX password: I cannot understand PCs[Enter]

Retype new UNIX password: I cannot understand PCs[Enter]

passwd: all authentication tokens updated successfully


1.4 Moving around directories

The filesystem is organizated in directory and subdirectory.

1.4.1 Current Directory

$ cd /usr/bin[Enter]

$ pwd[Enter]

/usr/bin


1.4.2 Absolute and relative path

The absolute path starts from the root directory while the relative one starts from the current directory.

$ cd /usr/local[Enter]

This is an absolute path since it starts with /.

$ pwd[Enter]

/usr/local

$ cd bin[Enter]

This is a relative one: it starts from the local directory moving downward to bin.

$ pwd[Enter]

/usr/local/bin


1.4.3 Moving backward

Every directory holds two references to special subdirectory:

single (.) that is a reference to the current directory.

double (..) that is a reference to the previous directory.

These symbols are effective directory names.

$ cd ..[Enter]

$ pwd[Enter]

/usr/local

$ cd ../bin[Enter]

$ pwd[Enter]

/usr/bin


You may go backward for more then one level.

$ cd ../../var/tmp[Enter]

$ pwd[Enter]


/var/tmp

$ cd /usr/bin/../local/bin/..[Enter]

$ pwd[Enter]

/usr/local

1.4.4 The precise reference to the current directory

The current directory can be seen as a single dot. In practice all relative paths can start with the prefix ./.

$ cd ./bin[Enter]

$ pwd[Enter]

/usr/local/bin


1.4.5 Home Directory

Every user has his own personal directory, known as home, it keeps all the data owned by the user. Typing just cd the user can reach his home directory.

$ cd[Enter]

$ pwd[Enter]

/home/radio

Some shells replace tilde (~) at the begging of a path with the path of the home directory of the working user.

$ cd ~[Enter]

$ pwd[Enter]

/home/radio

In the same way if tilde is set before a user account it will be replaced with the path of user's home directory.

$ cd ~ftp[Enter]

$ pwd[Enter]

/home/ftp

Going back to home directory.

$ cd[Enter]

1.5 File content

1.5.1 Directory content

To list the directory content command ls is used

$ ls /bin[Enter]



arch dd gzip netconf sleep
ash df hostname netstat sort
ash.static dmesg igawk nice stty
aumix-minimal dnsdomainname ipcalc nisdomainname su
awk doexec kill ping sync
basename domainname linuxconf ps tar
bash echo ln pwd tcsh
bash2 ed loadkeys red touch
bsh egrep login remadmin true
cat ex ls rm umount
chgrp false mail rmdir uname
chmod fgrep mkdir rpm userconf
chown fsconf mknod rvi usleep
consolechars gawk mktemp rview vi
cp gawk-3.0.4 more sed view
cpio grep mount setserial vimtutor
csh gtar mt sfxload ypdomainname
date gunzip mv sh zcat

The command ls /bin lists the content of /bin/.

A more expressive listing can be obtened using option -l.

$ ls -l /bin[Enter]

-rwxr-xr-x    1 root     root         2612 Mar  7 11:29 arch
-rwxr-xr-x 1 root root 60592 Feb 3 20:12 ash
-rwxr-xr-x 1 root root 263064 Feb 3 20:12 ash.static
-rwxr-xr-x 1 root root 9968 Feb 3 19:04 aumix-minimal
lrwxrwxrwx 1 root root 4 Apr 13 23:28 awk -> gawk
-rwxr-xr-x 1 root root 5756 Mar 7 12:15 basename
-rwxr-xr-x 1 root root 316848 Feb 27 18:44 bash

... many lines ...

-rwxr-xr-x    1 root     root         4320 Mar  7 12:15 true
-rwsr-xr-x 1 root root 26608 Feb 3 15:14 umount
-rwxr-xr-x 1 root root 6196 Mar 7 12:15 uname
lrwxrwxrwx 1 root root 14 Apr 13 23:49 userconf -> /bin/linuxco
nf
-rwxr-xr-x 1 root root 16252 Mar 8 17:26 usleep
-rwxr-xr-x 1 root root 346352 Mar 7 18:18 vi
lrwxrwxrwx 1 root root 2 Apr 14 00:00 view -> vi
-rwxr-xr-x 1 root root 362 Mar 7 18:18 vimtutor
lrwxrwxrwx 1 root root 8 Apr 13 23:51 ypdomainname -> hostname
-rwxr-xr-x 3 root root 46384 Feb 15 17:04 zcat

$ cd[Enter]

$ ls[Enter]

To list hidden files

$ ls -a[Enter]

.              .bash_history  .enlightenment       .mc
.. .bash_logout .gnome .tcshrc
.ICEauthority .bash_profile .gnome-desktop .xsession-errors
.Xauthority .bashrc .gnome-help-browser
.Xdefaults .cshrc .gnome_private


1.5.2 File Content

In order to analyse the file content cat,less and more ca be used (it doesn't make sense if it is a binary file).

$ cat /etc/issue[Enter]

Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0 on an i586


1.5.3 Find out the file type

file is command the uses the so called magic number (Unix tradition) to figure out the file type..

$ file /etc/*[Enter]

/etc/CORBA: directory

/etc/DIR_COLORS:           English text
/etc/HOSTNAME: ASCII text
/etc/X11: directory
/etc/adjtime: ASCII text
/etc/aliases: English text

...many lines...

/etc/shells:               ASCII text
/etc/skel: directory
/etc/smb.conf: English text
/etc/smrsh: directory
/etc/snmp: directory
/etc/sound: directory
/etc/sysconfig: directory
/etc/sysctl.conf: English text
/etc/syslog.conf: English text
/etc/termcap: English text
/etc/up2date.conf: can't read `/etc/up2date.conf' (Permission denied).
/etc/vga: directory
/etc/yp.conf: English text
/etc/ypserv.conf: English text

This method is not realible but can be useful.

1.5.4 Used and free space

In order to check the free space on disk you can use df.

$ df[Enter]

The result maybe something similar to this one.

Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda5 1511968 805300 629860 56% /
/dev/hda1 99521 2482 91900 3% /boot

To check the directory used space: du.

$ du /bin[Enter]

5240 /bin

In this case the /bin/ directory holds files for a total amount of 5240KB.

1.6 File creation, copy and deletion

1.6.1 File creation

There are different ways to create a file. The easiest way to create an empty file si to use touch. First move to the home directory, the best place where to play.

$ cd[Enter]

$ touch myfile[Enter]

$ ls -l myfile[Enter]

-rw-rw-r-- 1 radio radio 0 Dec 23 10:49 myfile

The file was created..

You can use cat too:

$ cat > myfile2[Enter]

there are better ways to write[Enter]

text.[Enter]

This is a oneway writing.[Enter]

[Ctrl+d]

$ cat myfile2[Enter]

1.6.2 File copy

$ cp myfile2 myfile3[Enter]

Group copy is possible only if the last file is an existing directory.

$ cp myfile myfile2 myfile3 /tmp[Enter]

$ cp myfile* /tmp[Enter]

1.6.3 File deletion

Becareful when you delete something as root!!

$ rm myfile myfile2[Enter]

There is noway to recover deleted files.

You can use the wild chars:* and ?.

$ ls myfile*[Enter]

myfile3

$ rm myfile*[Enter]

1.7 Working with directory

1.7.1 Directory creation

$ cd[Enter]

$ mkdir mydir[Enter]

Let's check with ls.

$ ls -l[Enter]

...

drwxr-xr-x 8 radio radio 1024 Dec 23 12:11 mydir

...

The d character at the beginning of the string tells has that the file is a directory.


1.7.2 Directory copy

cp with option -r or-R.

$ cp -r mydir mydir2[Enter]


1.7.3 Directory deletion

You may delete an empty directory using rmdir.

$ rmdir mydir2[Enter]

Let's try with something more complex.

$ mkdir carbon[Enter]

$ mkdir carbon/hydrogen[Enter]

$ mkdir carbon/oxygen[Enter]

$ mkdir carbon/hydrogen/helium[Enter]

$ rmdir carbon[Enter]

rmdir: carbon: Directory not empty

$ rm -r carbon[Enter]

1.8 Moving around directories and linking files

In Unix environment rename and moving a file are the same thing.


1.8.1 Moving and renaming

The command used is mv.

$ touch white[Enter]

$ touch green[Enter]

$ mkdir purple[Enter]

Let's check.

$ ls -l[Enter]

...

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 white

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 green

drwxrwxr-x 2 radio radio 1024 Dec 25 12:46 purple

...


Let's rename white file to make it brown.

$ mv white brown[Enter]

$ ls -l[Enter]

...

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 brown

...




To move more file all in once the destination must be a directory.

$ mv brown green purple[Enter]

$ ls -l purple[Enter]

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 green

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 brown

$ mv purple /tmp[Enter]

1.8.2 Linking

Instead of copying a file we may want to create a reference to it. There are two kind of links that can be created hard links and soft links. Let's see the soft one

The command is ln with the option -s.


Let's set the environment.

$ touch one[Enter]

$ touch two[Enter]

$ mkdir three[Enter]

Checking ..

$ ls -l[Enter]

...

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 two

drwxrwxr-x 2 radio radio 1024 Dec 25 12:46 three

-rw-rw-r-- 1 radio radio 0 Dec 25 12:46 one

$ ln -s one one.bis[Enter]

$ ls -l[Enter]

...

lrwxrwxrwx 1 radio radio 3 Dec 25 12:47 one.bis -> one

It's the same for directories.

$ ln -s /tmp miatemp[Enter]

$ ln -s /home/radio/one* /home/radio/two three[Enter]

$ ls -l three[Enter]

lrwxrwxrwx 1 radio radio 15 Dec 25 15:21 two -> /home/radio/two

lrwxrwxrwx 1 radio radio 15 Dec 25 15:21 one -> /home/radio/one

lrwxrwxrwx 1 radio radio 19 Dec 25 15:21 one.bis -> /home/radio/one.bis


1.9 The shell

The shell is the way to interact with the operative systme. The shell bash is the one used in our exercises.

1.9.1 Automatic fulfilling

The shell can fulfill a command using [Tab], this feature is particularly useful when you have file with long names.

$ touch microprocessor[Enter]

$ touch microscopic[Enter]

$ touch supersonic[Enter]

$ ls sup[Tab]

$ ls sup[Tab]ersonic[Enter]

$ ls mic[Tab]ro

$ ls mic[Tab]rop[Tab]rocessor[Enter]

1.9.2 Substitution: wild char

This is an alternative way to fulfill a command, it is the the shell that changes symbols with the right information.

1.9.2.1 Asterisk *

That symbol can be replaced with a sequence, from 0 to infinity, of symbols.

$ ls[Enter]

$ ls *[Enter]


This command is different, the shell changes the * with the list of files and directory held in the current directory. This means that if there is any subdirectory its content

would be displayed.

ls micro*[Enter]

microprocessor microscopic

* can be changed with null string:

$ touch millimicro[Enter]

$ ls *micro*[Enter]

microprocessor microscopic millimicro


1.9.2.2 Question mark ?

The question mark ? can be change with just one symbol

Let's create some files.

$ touch xy123j4[Enter]

$ touch xy456j5[Enter]

$ touch xy789j111[Enter]

$ touch xy78j67[Enter]

$ ls [Enter]

xy123j4
xy456j5
xy789j111
xy78j67

$ ls ?????j?[Enter]

xy123j4
xy456j5

We would have a different result using *

$ ls *j*[Enter]

xy123j4 xy456j5 xy789j111 xy78j67


1.9.2.3 Square brackets [ ]

The square brackets are used to have a range of symbols from which to choose the substitution symbols. Just one symbol from the one listed is used.

$ ls xy????[4567]*[Enter]

xy123j4 xy456j5

$ ls xy????[4-7]*[Enter]

1.9.2.4 Escape

For some special symbols you need to use escape

$ touch six\*height[Enter]

$ ls[Enter]

...

six*height


If you create a filename with a space inside

$ touch my\ letter[Enter]

$ ls[Enter]

...

my letter

six*height

1.9.3 Input/Output redirection and pipeline

The shell allows you to redirect command output from the standard output (usually the screen). The same for the input.

1.9.4 Redirection

$ ls -l > mylist[Enter]

$ cat mylist[Enter]

For the input .. instead of using the standard input (keyboard).

$ cat < mylist[Enter]

Appending to a file.

$
ls -l /tmp >> mylist[Enter]

$ cat mylist[Enter]


1.9.5 Pipeline

The pipeline is a way of redirecting input and output commands.

$ cat mylist | sort[Enter]

$ cat <>

Make it easier but without using pipeline.

$ sort <>

1.9.6 Alias

Aliases allows you to create an alternative name to an existing command.

$ alias ll='ls -l'[Enter]

$ ll[Enter]

This alias take options as an ordinary command.

$ ll micro*[Enter]

It's the same as ls -l micro*.

-rw-rw-r-- 1 radio radio 0 Dec 26 10:19 microprocessor

-rw-rw-r-- 1 radio radio 0 Dec 26 10:19 microscopic

This are the aliases that are usually created to avoid mistake

$ alias rm='rm -i'[Enter]

$ alias cp='cp -i'[Enter]

$ alias mv='mv -i'[Enter]

Now try to remove a file.

$ rm microprocessor[Enter]

rm: remove `microprocessor'?:

n[Enter]

In this way the file was not removed.

1.10 Searching

Searching files or directories it's an important task in a filesystem as complex as the Linux (or Unix) one.

1.10.1 Find

Searching a file or directory using its name or other external feature find command is used.

$ find / -name bash -print[Enter]

This command search for files and directory named bash inside all the directory starting from the root directory (/).

/bin/bash

...

find: /var/run/sudo: Permission denied

find: /var/spool/at: Permission denied

find: /var/spool/cron: Permission denied

...

You can use wild chars, in this case it will be the find command that will have to manage them, without using shell.

$ find / -name \*sh -print[Enter]

The escape char \ tells the shell not to translate the * as wild char.

/bin/bash

/bin/ash

/bin/sh

...

1.10.2 Grep
To search inside the content of a file grep is used.

$ grep radio /etc/*[Enter]

/etc/group:radio::500:radio

/etc/passwd:radio:Ide2ncPYY1234:500:500:radiolab:/home/radio:/bin/bash
grep: /etc/skel: Is a directory
grep: /etc/sudoers: Permission denied
...


1.16 References

Matt Chapman, Frankie Blaskovic, The Guide -- A Beginners Guide to UNIX

http://www.belgarath.demon.co.uk/guide/

Christopher C. Taylor, Unix is a Four Letter Word... and Vi is a Two Letter Abbreviation

http://www.linuxbox.com/~taylor/4ltrwrd/

Basic Linux Commands with man pages

Here are some basic commands to get you started in the wonderful world of Linux and other UNIX variants. All of these commands should work from your command prompt (regardless which shell you’re using).You MUST press enter to invoke the command.All UNIX and Linux commands are case sensitive. There are of course thousands of Linux related commands and procedures.

You can also execute multiple commands by separating each one with a ; for example cd newdir; mkdir thatdir ; ls -la will first change directories to the newdir directory, then create a directory called thatdir, then list all the files in long format. You can string together as many commands as you like but caution should be used not to inadvertently do anything harmful.

If you think some thing need to be added to this list let me know.

access - determine whether a file can be accessed

Syntax

access -mode file

For more options and how to use check access man page

alias - define or display aliases

Syntax

alias [alias-name[=string] …]

For more options and how to use check alias man page

bg - run jobs in the background

Syntax

bg [job_id …]

For more options and how to use check bg man page

cal - displays a calendar

Syntax

cal [-smjy13 ] [[ month ] year ]

For more options and how to use check cal man page

cd - change directories

Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below.

Syntax

cd [-L | -P] [directory]

For more options and how to use check cd man page

chown - change file owner and group

Syntax

chown [OPTION] OWNER[:[GROUP]] FILE

chown [OPTION] :GROUP FILE

chown [OPTION] –reference=RFILE FILE

For more options and how to use check chown man page

chmod - change file access permissions

Syntax

chmod [-r] permissions filenames

Options

r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format.filenames File or directory that you are associating the rights with Permissions

u - User who owns the file.

g - Group that owns the file.

o - Other.

a - All.

r - Read the file.

w - Write or edit the file.

x - Execute or run the file as a program.

Numeric Permissions:

CHMOD can also to attributed by using Numeric Permissions:

400 read by owner

040 read by group

004 read by anybody (other)

200 write by owner

020 write by group

002 write by anybody

100 execute by owner

010 execute by group

001 execute by anybody

For more options and how to use check chmod man page

cp - Copy files and directories

Syntax

cp [OPTION]… SOURCE DEST
cp [OPTION]… SOURCE… DIRECTORY
cp [OPTION]… –target-directory=DIRECTORY SOURCE…

Options

cp myfile yourfile

Copy the files “myfile” to the file “yourfile” in the current working directory. This command will create the file “yourfile” if it doesn’t exist. It will normally overwrite it without warning if it exists.

cp -i myfile yourfile

With the “-i” option, if the file “yourfile” exists, you will be prompted before it is overwritten.

cp -i /data/myfile

Copy the file “/data/myfile” to the current working directory and name it “myfile”. Prompt before overwriting the file.

cp -dpr srcdir destdir

Copy all files from the directory “srcdir” to the directory “destdir” preserving links (-poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir

For more options and how to use check cp man page

clear - Clears the terminal screen.

Syntax

clear

For more options and how to use check clear man page

cmp - Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs.

Syntax

cmp [-clsv] [-i NUM] [–help] [–print-chars] [–ignore-initial=NUM] [–verbose] [–quiet] [–silent] [–version] -I FILE1 [FILE2 [RANGE1 [RANGE2]]]

For more options and how to use check cmp man page

cat - Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.

Syntax

cat [OPTION] [FILE]…

For more options and how to use check cat man page

diff - find differences between two files

Syntax

diff [options] from-file to-file

For more options and how to use check diff man page

dmesg - Prints the messages resulting from the most recent system boot.

Syntax

dmesg [ -c ] [ -n level ] [ -s bufsize ]

For more options and how to use check dmesg man page

du - estimate file space usage

Syntax

du [OPTION]… [FILE]…

For more options and how to use check du man page

df - report filesystem disk space usage

Syntax

df [OPTION]… [FILE]…

For more options and how to use check df man page

exit - cause the shell to exit

syntax

exit [n]

For more options and how to use check exit man page

eject - eject removable media

Syntax

eject -h
eject [-vnrsfqp] []
eject [-vn] -d
eject [-vn] -a on|off|1|0 []
eject [-vn] -c slot []
eject [-vn] -t []
eject [-vn] -x []
eject -V

For more options and how to use check eject man page

fuser - identify processes using files or sockets

Syntax

fuser [-a|-s|-c] [-4|-6] [-n space] [-k [-i] [-signal] ] [-muvf] name
fuser -l
fuser -V

For more options and how to use check fuser man page

fsck - check and repair a Linux file system

Syntax

fsck [ -sACVRTNP ] [ -t fstype ] filesys [ … ] [–] [ fsck-options ]

For more options and how to use check fsck man page

fdisk - Partition table manipulator for Linux

Syntax

fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device
fdisk -l [-u] device …
fdisk -s partition …
fdisk -v

For more options and how to use check fdisk man page

fg - run jobs in the foreground

Syntax

fg [job_id]

For more options and how to use check fg man page

file - determine file type

Syntax

file [ -bciknsvzL ] [ -f namefile ] [ -m magicfiles ] file …
file -C [ -m magicfile ]

For more options and how to use check file man page

find - search for files in a directory hierarchy

Syntax

find [path…] [expression]

For more options and how to use check find man page

finger - Prints descriptions of the specified users.

Syntax

finger [-lmsp ] [user … ] [user@host … ]

For more options and how to use check finger man page

free - Displays the amount of used and free system memory.

Syntax

free [-b | -k | -m] [-o] [-s delay ] [-t] [-V]

For more options and how to use check free man page

ftp - A File Transfer Protocol client

Syntax

ftp hostname or ipaddress

For more options and how to use check ftp man page

grep, egrep, fgrep - print lines matching a pattern

Syntax

grep [options] PATTERN [FILE…]
grep [options] [-e PATTERN | -f FILE] [FILE…]

For more options and how to use check grep, egrep, fgrep man page

head - output the first part of files

Syntax

head [OPTION]… [FILE]…

For more options and how to use check head man page

history - Manipulate the history list

Syntax

history option arg arg …

For more options and how to use check history man page

!!

use the ! option. To automatically re-display the last command you typed at the prompt, type: !! and press enter. Press again to invoke the command. You can also automatically re-display a command you typed earlier by using the ! and the first few letters of the command.

& operator

execute a command as a background process.

Ex:-

#top&

init - process control initialization

Syntax

/sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ]

For more options and how to use check init man page

ispell - ispell, buildhash, munchlist, findaffix, tryaffix, icombine, ijoin - Interactive spelling checking

Syntax

ispell [common-flags] [-M|-N] [-Lcontext] [-V] files
ispell [common-flags] -l
ispell [common-flags] [-f file] [-s] {-a|-A}
ispell [-d file] [-w chars] -c
ispell [-d file] [-w chars] -e[e]
ispell [-d file] -D
ispell -v[v]

For more options and how to use check ispell man page

id - Print real and effective user id (uid) and group id (gid), prints options about the given user, or if no user is specified the process running it

Syntax

id [options]… [username]

For more options and how to use check id man page

kill - terminate a process

Syntax

kill [ -s signal | -p ] [ -a ] [ — ] pid … kill -l [ signal ]

For more options and how to use check kill man page

killall - kill processes by name

Syntax

killall [-Z,–context pattern] [-e,–exact] [-g,–process-group] [-i,–interactive] [-q,–quiet] [-r,–regexp] [-s,–signal signal] [-u,–user user] [-v,–verbose] [-w,–wait] [-I,–ignore-case] [-V,–version] [–] name … killall -l killall -V,–version

For more options and how to use check killall man page

logname - Print current login name

Syntax

logname [OPTION]

For more options and how to use check logname man page

less - Opposite of the more command

Syntax

less -?
less –help
less -V
less –version
less [-[+]aBcCdeEfFgGiIJmMnNqQrRsSuUVwWX]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,…] [-y lines] [-[z] lines]
[+[+]cmd] [–] [filename]…

For more options and how to use check less man page

logout - to quit using the system

Syntax

logout

lsof - list open files

Syntax

lsof [ -?abChlnNOPRstUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d d ] [ +|-D D ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl] ] [ -z [z] ] [ — ] [names]

For more options and how to use check lsof man page

ls - Short listing of directory contents

Syntax

ls [OPTION]… [FILE]…

Options

-a list hidden files

-d list the name of the current directory

-F show directories with a trailing ‘/’

executable files with a trailing ‘*’

-g show group ownership of file in long listing

-i print the inode number of each file

-l long listing giving details about files and directories

-R list all subdirectories encountered

-t sort by time modified instead of name

For more options and how to use check ls man page

ln - make links between files

Syntax

ln [OPTION]… TARGET [LINK_NAME]
ln [OPTION]… TARGET… DIRECTORY
ln [OPTION]… –target-directory=DIRECTORY TARGET…

Option

ln -s test symlink

Creates a symbolic link named symlink that points to the file test Typing “ls -i test symlink” will show the two files are different with different inodes. Typing “ls -l test symlink” will show that symlink points to the file test.

For more options and how to use check ln man page

locate - list files in databases that match a pattern

Syntax

locate [-d path | –database=path] [-e | –existing] [-i | –ignore-case ] [–version] [–help] pattern…

For more options and how to use check locate man page

mail - Launches a simple mail client that permits sending and receiving email messages.

Syntax

mail [OPTION…] [address…]

For more options and how to use check mail man page

man - an interface to the on-line reference manuals

Syntax

man [-c|-w|-tZHT device] [-adhu7V] [-m system[,…]] [-L locale] [-p string] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [[section] page …] …
man -l [-7] [-tZHT device] [-p string] [-P pager] [-r prompt] file …
man -k [apropos options] regexp …
man -f [whatis options] page …

For more options and how to use check man man page

mkdir - make directories

Syntax

mkdir [OPTION] DIRECTORY

Options

Create the Directory(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.

-m, mode=MODE set permission mode (as in chmod)

-p, parents no error if existing, make parent directories as needed

-v, verbose print a message for each created directory

-help display this help and exit

-version output version options and exit

For more options and how to use check mkdir man page

mount - mount a file system

Syntax

mount [-lhV]
mount -a [-fFnrsvw] [-t vfstype] [-O optlist]
mount [-fnrsvw] [-o options [,…]] device | dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir

For more options and how to use check mount man page

mv - change the name of a directory

Type mv followed by the current name of a directory and the new name of the directory
Syntax

mv [OPTION]… [-T] SOURCE DEST mv [OPTION]… SOURCE… DIRECTORY mv [OPTION]… -t DIRECTORY SOURCE…

Ex: mv testdir newnamedir

For more options and how to use check mv man page

more - Allows file contents or piped output to be sent to the screen one page at a time.

Syntax

more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file … ]

For more options and how to use check more man page

nohup - run a command immune to hangups, with output to a non-tty

Syntax

nohup COMMAND [ARG]…
nohup OPTION

For more options and how to use check nohup man page

nice - run a program with modified scheduling priority

Syntax

nice [OPTION] [COMMAND [ARG]…]

For more options and how to use check nice man page

ping - send ICMP ECHO_REQUEST packets to network hosts

Syntax

ping [-Rdfnqrv ] [-c count ] [-i wait ] [-l preload ] [-p pattern ] [-s packetsize ] host

For more options and how to use check ping man page

ps - report process status

Syntax

ps [options]

For more options and how to use check ps man page

pwd - print working directory

will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page.

Syntax

pwd [OPTION]

For more options and how to use check pwd man page

passwd - change user password

Syntax

passwd [-f|-s] [name]
passwd [-g] [-r|R] group
passwd [-x max] [-n min] [-w warn] [-i inact] name
passwd {-l|-u|-d|-S|-e} name

For more options and how to use check passwd man page

reboot - Reboots the system (requires root privileges).

Syntax

/sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h] /sbin/reboot [-n] [-w] [-d] [-f] [-i] /sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h]

For more options and how to use check reboot man page

rmdir - remove empty directories

Syntax

rmdir [OPTION]… DIRECTORY…

For more options and how to use check rmdir man page

rm - remove files or directories

Syntax

rm [OPTION]… FILE…

Option

rm -r - Removes directories and files within the directories recursively.

For more options and how to use check rm man page

renice - alter priority of running processes

Syntax

renice priority [[-p ] pid … ] [[-g ] pgrp … ] [[-u ] user … ]

For more options and how to use check renice man page

shutdown - bring the system down

Syntax

/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message]

For more options and how to use check shutdown man page

sleep - delay for a specified amount of time

Syntax

sleep NUMBER[SUFFIX]…
sleep OPTION

For more options and how to use check sleep man page

sort - sort lines of text files

Syntax

sort [OPTION]… [FILE]…

For more options and how to use check sort man page

split - split a file into pieces

Syntax

split [OPTION] [INPUT [PREFIX]]

For more options and how to use check split man page

slocate - Security Enhanced version of the GNU Locate.

Syntax

slocate [-qi] [-d] [–database= ]
slocate [-i] [-r ] [–regexp=]
slocate [-qv] [-o ] [–output=] slocate [-e ] [-f ] <[-l ] [-c] <[-U ] [-u]>
slocate [-Vh] [–version] [–help]

For more options and how to use check slocate man page

sync - synchronize data on disk with memory

Syntax

sync [–help] [–version]

For more options and how to use check sync man page

su - run a shell with substitute user and group IDs

Syntax

su [OPTION]… [-] [USER [ARG]…]

For more options and how to use check su man page

telnet - user interface to the TELNET protocol

Syntax

telnet [-8] [-E] [-F] [-K] [-L] [-S tos] [-X authtype] [-a] [-c] [-d] [-e escapechar] [-f] [-k realm] [-l user] [-n tracefile] [-r] [-x] [host [port]]

For more options and how to use check telnet man page

top - display top CPU processes

Syntax

top [-] [d delay] [p pid] [q] [c] [C] [S] [s] [i] [n iter] [b]

For more options and how to use check top man page

talk - talk to another user

Syntax

talk person [ttyname]

For more options and how to use check talk man page

tree - list contents of directories in a tree-like format.

Syntax

tree [-adfgilnopqrstuxACDFNS] [-L level [-R]] [-H baseHREF] [-T title] [-o filename] [–nolinks] [-P pattern] [-I pattern] [–inodes] [–device] [–noreport] [–dirsfirst] [–version] [–help] [directory …]

For more options and how to use check tree man page

tr - translate or delete characters

Syntax

tr [OPTION]… SET1 [SET2]

For more options and how to use check tr man page

time - time a simple command or give resource usage

Syntax

time [options] command [arguments…]

For more options and how to use check time man page

tty - print the file name of the terminal connected to standard input

Syntax

tty [OPTION]…

For more options and how to use check tty man page

touch - change file timestamps

Syntax

touch [OPTION]… FILE…

For more options and how to use check touch man page

tail - output the last part of files

Syntax

tail [OPTION]… [FILE]…

For more options and how to use check tail man page

traceroute - print route packets take to network host

Syntax

traceroute [-adnruvAMOQ] [-w wait_time] [-S start_ttl] [-m max_ttl] [-p port] [-q nqueries] [-g gateway] [-t tos] [-s src_addr] [-g router] host [packet size]

For more options and how to use check traceroute man page

uptime - Tell how long the system has been running.

Syntax

uptime
uptime [-V]

For more options and how to use check uptime man page

umount - unmount file systems

Syntax

umount [-hV]
umount -a [-dflnrv] [-t vfstype] [-O options]
umount [-dflnrv] dir | device […]

For more options and how to use check umount man page

umask - get or set the file mode creation mask

Syntax

umask [-S][mask]

For more options and how to use check umask man page

ulimit - Control the resources available to a process started by the shell, on systems that allow such control.

Syntax

ulimit [-acdfHlmnpsStuv] [limit]

For more options and how to use check ulimit man page

uname - print system options

Syntax

uname [OPTION]…

For more options and how to use check uname man page

uniq - report or omit repeated lines

Syntax

uniq [OPTION]… [INPUT [OUTPUT]]

For more options and how to use check uniq man page

vdir - list directory contents

Syntax

vdir [OPTION]… [FILE]…

For more options and how to use check vdir man page

w - Show who is logged on and what they are doing.

Syntax

w - [husfV] [user]

For more options and how to use check w man page

wall - send a message to everybody’s terminal.

Syntax

wall [-n] [ message ]

For more options and how to use check wall man page

who - show who is logged on

Syntax

who [OPTION]… [ FILE | ARG1 ARG2 ]

For more options and how to use check who man page

whoami - print effective userid

Syntax

whoami [OPTION]…

For more options and how to use check whoami man page

watch - execute a program periodically, showing output fullscreen

Syntax

watch [-dhv] [-n ] [–differences[=cumulative]] [–help] [–interval=] [–version]

For more options and how to use check watch man page

whereis - locate the binary, source, and manual page files for a command

Syntax

whereis [ -bmsu ] [ -BMS directory… -f ] filename …

For more options and how to use check whereis man page

wc - print the number of newlines, words, and bytes in files

Syntax

wc [OPTION]… [FILE]…

For more options and how to use check wc man page

xload - system load average display for X

Syntax

xload [-toolkitoption …] [-scale integer] [-update seconds] [-hl color] [-highlight color] [-remote host] [-jumpscroll pixels] [-label string] [-nolabel] [-lights]

For more options and how to use check xload man page