Getting Started

Topics:

Commands:

logout
exit
pwd
cd
ls
less
more
useradd
passwd
cat
groupadd
tail
usermod
userdel
man
halt
shutdown
init
reboot
date
cal
who
finger
mail
wall
wc
clear
whoami

Logging On and Off the System

Logging In
hostname login: username
Password: (password does not echo)
[username@hostname username]$
Logging Out from console (all 3 work)
$ logout
$ exit
$ <Ctrl-d>

Logging Out: Using the GUI

Moving Around

Creating User Accounts

    or
[root@hostname /root]# passwd username
# cat /etc/passwd

sudo

Creating Groups

Passwords

Command Syntax

Linux/Unix commands have the following syntax:
$ command option(s) argument(s)
The elements of a command are:

Primary Group and Additional Groups

Create an account complete with home directory, shell, and environment template

Lab

1. Create the account student, with the primary group users specified

    $ less /etc/group
    $ less /etc/group | grep users
    

    $ tail /etc/passwd
    
2. Add the user account student to the additional group, admins

    $ sudo groupadd admins
    $ tail /etc/group
    

    $ sudo  usermod -G admins student
    $ tail /etc/group
    
3. Delete an account

   $ sudo useradd pattyo -m -d /home/pattyo
   $ ls -l /home
   $ sudo userdel -r pattyo
   $ ls -l /home
    

Help Files and Man Pages

$ man useradd
$ useradd -h
$ useradd -help

Shutdown and Reboot from command line

    halt machine now
# halt
    halt machine using shutdown command
# /sbin/shutdown -h now
    shutdown machine using run-level command (this is an advanced concept we will talk about later)
# init 0
    shutdown and reboot now
# /sbin/shutdown -r now
    reboot
# /usr/bin/reboot
Note: You can also use the GUI to shutdown your machine without being root -- look for the red icon in the upper right hand corner of your GNOME desktop.

Getting around...recalling other commands

The date and cal commands

$ date
Wed Nov 29 11:14:26 PST 2000
$ !!
Wed Nov 29 11:14:27 PST 2000
Looking at a Whole Month

$ cal 12 1999
      December 1999
 Su  Mo  Tu  We  Th  Fr  Sa
              1   2   3   4
  5   6   7   8   9  10  11
 12  13  14  15  16  17  18
 19  20  21  22  23  24  25
 26  27  28  29  30  31

Looking at a Whole Year

$ cal 2002

Piping output through the more (I prefer less) command

$ cal 2002 | more
$ cal 2002 | less

The pipe is used to pipe the output of one command into the input of another. We'll talk more about it later.

The who and finger Commands

    Finding who is currently logged onto the System     Finding Who You Are (returns the name of the user running the command)
$ who am i
user10  tty1  Feb 12 11:10  - OR -  user10

$ whoami
user10

    The finger Command
$ finger userxx
Name:
Login: userxx      Shell: /bin/bash
Directory: /home/userxx
On since Fri Feb 12 10:32 (CST) on tty2
No mail.
No Plan
The .project and .plan files live in your home directory. You can create these to add details to your login information.
Sending Mail

    Sending a Message to Someone on the Same System

$ mail student
Subject: Meeting
Hey there!  Don't forget the party this weekend.
Fred
<Ctrl-d>
Cc: <Enter>

Note: the <Ctrl-d> exit the body of the message. Or a single '.' on a line by itself

    Sending a Message to Someone on Another System

    You can use a Ctrl-d or a single period '.' to exit the body of the message.

Receiving Mail

Actually, by default, Linux will tell you when you login:

You have mail.

To check your mail without using the GUI:

$ mail
Mail version 8.1.6/6/93  Type ? for help
"/var/spool/mail/team01": 2 messages 1 new
  U 1 team05@hostname.local Mon Jan 25 10:50 10/267 "Call Us, re:Meeting"
>N 2 team02@hostname.local Tue  Jan 26 09:05 16/311 "Meeting Postponed"
& <Enter>
Message 1:
From team05 Mon Jan 25 10:50:32 1999
Date: Mon, Jan 25 1999 10:50:32 -600
From: team05@hostname.localdomain
To: pattyo@hostname.localdomain
Subject: Meeting
Please call us regarding the status of the meeting we called for Thursday morning.

    Some mail options to be entered at '&' prompt:

Configuring mail

In order to send mail to another domain from your workstation, you will need to install, configre, and run an MTA (Mail Transport Agent). Postfix is easy to install and configure. This is a great website to use as a reference: http://flurdy.com/docs/postfix/.


   $ sudo apt-get install postfix
   $ cd /etc/postfix
   $ sudo vi main.cf
   $ sudo /etc/init.d/postfix start

The wall Command

    To Display Text Immediately on All Users' Terminals connected to your machine
  # wall textofmessage

    Example:

    This is what 'root' might send:

# wall Warning -- System Going Down Immediately!

This is what every logged in user would receive:

Broadcast message from root (ttyp1) Tue Jan 26 14:04:48 1999
Warning!! System Going Down!

To reboot the system and notify users:

# /sbin/shutdown -r +5 "rebooting to clear hung mounts in 5 minutes... "

The write and talk commands

The clear, echo and wc Commands

    The clear Command

Is your screen full of confusing data, messages, etc?

$ clear

    The echo Command
  • Very useful in shell scripts when you need to be signaled when certain instructions are executed.
  • Provides a quick way to enter text into a file or command.
# echo "10.2.135.200  linux4804.miracosta.edu" >> /etc/hosts

$ echo Installing modem drivers now?
Installing modem drivers now?

    The wc command
  • Determining the size of input in characters, lines, or words
Syntax:

wc [-c] [-l] [-w] filename

The options

  • -c counts the number of characters (i.e., the number of bytes);
  • -l counts the number of lines; and
  • -w counts the number of words.
Example:

$ wc /etc/passwd

and you get:

24  30  875  /etc/passwd

order: Lines, Words, Characters, Name of File

You could also use 'wc' with an option to find out how many entries are in your /etc/passwd file.

$ wc -l /etc/passwd
24

Keyboard Tips and Shortcuts

Keyboard Keys Function
<Backspace > Corrects input mistakes
<Ctrl-c> Terminates the current command or process and returns to the shell
<Ctrl-d> End of transmission or end of file
<Ctrl-s> Temporarily stops output to the screen
<Ctrl-q> Resumes output on the screen which has been stopped by <Ctrl-s>
<Ctrl-u> Erases the entire line

Summary