Logging Out from console (all 3 work)hostname login: username
Password: (password does not echo)
[username@hostname username]$
$ logout
$ exit
$ <Ctrl-d>
$ cd
$ ls
$ ls /etc
$ ls -l /etc
$ ls -l /etc | less
$ ls -l /etc | more
[root@hostname /root]# passwd username
Root is equivalent to the local Administrator account in Windows 2000/NT
Where are these new user account records stored? Use the cat command to print the ascii passwd file to the terminal.
# cat /etc/passwd
$ groupadd
usage: groupadd [-g gid [-o]] [-r] [-f] group
$ sudo groupadd mynewgroup
# tail /etc/group
$ passwd
Changing password for
- Make them at least eight characters long;
- Don't let them contain dictionary words;
- Don't make a new one similar to the current/last one;
- They have to have a varied selection of characters;
- They are case-sensitive;
- No, the system administrator should NOT have a record of it.
$ command option(s) argument(s)
The elements of a command are:
$ sudo useradd -c "Test Account" -d /home/test -s /bin/bash -g users testuser
1. Create the account student, with the primary group users specified
- Remember, the primary group is part of the user's passwd file record
$ sudo useradd student -g users -m -d /home/student
- How do you know the users group exists?
- Take a look at the /etc/group file
$ less /etc/group $ less /etc/group | grep users
- Look at the passwd file to see the new account
- Field 1, is the user account name, field 3 is the UID, field 4 is the primary group (the fields are separated by a colon)
$ tail /etc/passwd
2. Add the user account student to the additional group, admins
- First create the group
$ sudo groupadd admins $ tail /etc/group
- Add the user to admins
$ 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
- The '-r' tells userdel to remove all the files in the user's home directory.
- Why use the command line when a GUI is available?
|
|
|
|
$ man useradd
$ useradd -h
$ useradd -help
# halthalt machine using shutdown command
# /sbin/shutdown -h nowshutdown machine using run-level command (this is an advanced concept we will talk about later)
# init 0shutdown and reboot now
# /sbin/shutdown -r nowreboot
# /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.
$ 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 31Looking at a Whole Year
$ cal 2002
Piping output through the more (I prefer less) command
$ cal 2002 | more
$ cal 2002 | lessThe pipe is used to pipe the output of one command into the input of another. We'll talk more about it later.
$ who -u
$ w
$ who am iThe finger Command
user10 tty1 Feb 12 11:10 - OR - user10$ whoami
user10
Sending Mail
- For information about specific logged in users
$ finger userxxThe .project and .plan files live in your home directory. You can create these to add details to your login information.
Name:
Login: userxx Shell: /bin/bash
Directory: /home/userxx
On since Fri Feb 12 10:32 (CST) on tty2
No mail.
No Plan
Sending a Message to Someone on the Same System
$ which mail
$ aptitude search mail
$ sudo apt-get install mailx
$ 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
Userxy
.
Cc: <Enter>
Actually, by default, Linux will tell you when you login:You have mail.
To check your mail without using the GUI:
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.
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
myhostname = mymachine.mydomain.com relayhost = smtphost.mydomeain.com
# wall textofmessageExample:
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... "
$ w
12:31am
up 10 days, 57 min, 8 users, load average: 0.21, 0.22, 0.15
USER
TTY
FROM
LOGIN@
IDLE JCPU PCPU WHAT
pattyo
tty1
-
22Aug02 8days 0.50s 0.03s /bin/sh /usr/X1
pattyo pts/0
michoacan.home
Wed 1pm 8:12m 0.32s 0.17s -bash
pattyo pts/5
-
24Aug02 8days 0.00s ? -
pattyo pts/6
-
24Aug02 8:44m 0.36s 0.36s /bin/bash
pattyo pts/7
-
24Aug02 0.00s 1.49s 0.05s w
pattyo pts/8
-
24Aug02 8:31m 0.81s 0.81s /bin/bash
$ write pattyo pts/8
Note: you may need to make yourself available to receive messages:
$ mesg y
The clear Command
Is your screen full of confusing data, messages, etc?The echo Command$ clear
The wc command# echo "10.2.135.200 linux4804.miracosta.edu" >> /etc/hosts
- 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 Installing modem drivers now?
Installing modem drivers now?
Syntax:
- Determining the size of input in characters, lines, or words
wc [-c] [-l] [-w] filename
The options
Example:
- -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.
$ 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 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 |
ls
man ls
/etc/passwd
/etc/group
useradd
groupadd
command -option(s) argument
who
wall, write, mail
halt, shutdown, init 0
wc
echo
clear
whoami, who am i, finger
cal, date