-
Different ways to run command-line interface
- As a terminal session from GUI
- Start Linux at Run level 3 (no GUI)
- Start Linux at Run level 1 (emergency)
-
Default shell for user specified in
/etc/passwd
-
Virtual Terminal
- Linux supports Virtual Terminal (VT) sessions
- Ususally 6 or 7 sessions by default
- Access each VT by combination of key strokes
- CTRL + ALT + Fn (Fn: where “n” is a number)
- Return to original session: CTRL + ALT + F1
-
Logging in Remotely
- Remote access must be enabled using a daemon
- Use “telnet” or “rlogin” but unsecure
- “ssh” Secured Shell is best (provides encryption)
- Configure “ssh” for remote logins
- Once “ssh” is running on server, client connections can be established:
- Command: ssh servername or
- ssh IP Address
- When connected you will be required to login using a valid user account and password
- “ssh” on client can be used with different O/Ss
- Once connected user has access as if local
- When finished, logout
-
free
- echo
- cat
- free : show free disk space
- echo : $PATH show the contents of path
- cat textfile : show the contents of file
-
&
- ctrl+Z, bg #
- fg #
- Start in background: firefox &
- Move to background: Ctrl+Z, bg #
- Move to foreground: fg #
-
Using Command Completion
- Uses tab key
- Completes commands, filenames, or directory names
-
Using Command History
- Use the history command to see all
- Use the history # to see the last # commands.
- Press up arrow to see last command.
- Use various keystrokes to recall and edit
-
Getting Help
- Lots of help available
- Linux commands:
- –man (pages) sections 1,5,8
- –info
- Readme type files
- Discussion forums
- Online documentation
- Ask questions
-
“whatis” command
- helpful to get brief information about Linux commands or functions
- displays man page single line description for command that matches string passed as a command line argument to whatis command
- picks short description of NAME section of man page of command that matches to input given to the whatis command
- Example: whatis passwd
-
man page section numbers
- 1. Executable programs and shell commands
- 5. File formats
- 8. System administration commands (programs run mostly or exclusively by root)
-
get help on the file “passwd” not the command
- versus
- get help on the command “passwd”
- man 5 passwd
- man passwd
-
searching man page
- whatis” command
- Searches summary information contained in man pages
- Uses keywords
- Returns one line summary for every matching man page
- “apropos” command
- Performs a more thorough search
- Searches both Name and Description sections of “man” pages
-
“less” command
- A pager command
- Displays text a screen at a time
- Move forward and back through the file
- Search for keywords (highlighted)
- Can be used to read other text files
-
“info” Pages
- A newer documentation system
- Similar to “man” pages but more features
- Provides for hypertext linking to other pages
- Each page is known as a “node”
- Documentation for a specific command can be split across multiple nodes
- Link to different nodes then return back (use the”u” key to return”
- See Table 8.3 page 139 for key functions
- Man pages do not provide this
-
-
ls -lai
- -a all files, including hidden(starting with a .)
- -i i-node numbers
-
Move to the user’s home directory
-
-
whatis <command name>
$ whatis passwd
finds man page entries for the command
-
passwd (5) - the password file
- passwd (1) - change user password
- passwd (1ssl) - compute password hashes
-
apropos
$ apropos passwd
performs a more thorough search
-
chgpasswd (8) - update group passwords in batch mode
- chpasswd (8) - update passwords in batch mode
- fgetpwent_r (3) - get passwd file entry reentrantly
- getpwent_r (3) - get passwd file entry reentrantly
- gpasswd (1) - administer /etc/group and /etc/gshadow
-
whoami
- mkdir
- cd
- touch
- tree <folder name>
- ls -la
-
change the name of report to document
move all files to parent directory
remove deleteme from parent dir
mv report document
mv * ..
rm ../deleteme
-
STDOUT Redirection
- Issue the following command to redirect STDOUT, instead of writing information to the monitor it will create a file and place the output in the file
- Command: cat /etc/services > outfile Run the command: ls –l you will see the file “outfile”
-
To add to the end of the file(outfile) created
- To add to the end of the file created above use the “>>”
- Command: ls -l >> outfile
- Run the command: ls –l you will see the file “outfile”
- Run the command
- cat outfile
- The above command will display the contents of “outfile” you will see the results of both of the previous commands
-
>
- >>
- “>” this means create a new file, if a file exists it will be overwritten “>>” this means append to the end of a file, if the file does not exist it will be created
-
To prevent information from scrolling to the end;
use the pipe “|” and “more”
Example: ls –l | more
-
To search for a specific pattern use
the “grep” program as follows: Run the command: ls –l | grep conf
|
|