Unix – General

- Forwarding Xsession
HOST xhost + (server IP or hostname) CLIENT ssh –Y user@server
…server = IP or hostname
…Y Enables trusted X11 forwarding. Trusted X11 forwarding is not subjected to the X11 SECURITY extension controls.

- /etc/shadow
username:encryptedpassword:13055:60:90:5:-1:365:
1 2 3 4 5 6 7 8
1. User name : It is your login name
2. Password: It your encrypted password. The password should be minimum 6-8 characters long including special characters/digits
3. Last password change (lastchanged): Days since Jan 1, 1970 that password was last changed
4. Minimum: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her password
5. Maximum: The maximum number of days the password is valid (after that user is forced to change his/her password)
6. Warn : The number of days before password is to expire that user is warned that his/her password must be changed
7. Inactive : The number of days after password expires that account is disabled
8. Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used

- Directory Listing
>ls -l : ll

>ls -1 : displays file name only. useful for scripts-

- User login history
>last | more : this will show you who has logged onto the system, which IP they have logged in from, what time and date they logged in and whether or not they are still currently logged into the system. # crontab
>crontab -l : lists the contents of the crontab schedule
>crontab -e : either allows you to edit crontab schedule or creates a blank schedule if none exist

- list crontab file
>crontab -l

- edit crontab file
>crontab -e

- crontab file layout
* * * * * command to be executed
- – – – -
| | | | |
| | | | +—– day of week (0 – 6) (Sunday=0)
| | | +——- month (1 – 12)
| | +——— day of month (1 – 31)
| +———– hour (0 – 23)
+————- min (0 – 59)

$var     An environment variable, where “var” is the name and a value can be seen using “echo $var”
&      Run a program in the background example “netscape &” this frees up your command line to run other apps
alias      Aliases can be used to make a shortcut for a common command
cat      Concatenate and display files, used to output a file’s contents without pausing example: “cat textfile”
chgrp      Change a file’s group example: “chgrp users /bin/ls”
chmod      Change a file’s mode or permissions one way is to use octal numbering example: “chmod 751 /bin/ls” for rwxr x
chown      Change a file’s owner example: “chown uzi /bin/ls”
crontab      Schedule regular programs to run at certain times (some let all users have their own crontab file)
CTRL Z      Suspend a running program
CTRL C      Kill a running program
date      Print current time and date
df      Find out how much free disk space is available example: “df k .” for current directory in kilobytes
du      Find out disk usage of a file or directory example: “du ks ~” for size of your entire home directory
fg,  bg      Put a suspended program in the foreground or background
find      Find a file, second argument is where to search from example: “find . name ‘*.c’ print”
finger       Get information on another user on the system example: “finger username”
grep      Look for text in a file example: “grep variable *.c”
gzip, gunzip     Compress or uncompress *.gz files example: “gzip file.tar”
jobs     List running programs of this terminal
kill     Kill a running process example: “kill CODE PID”, where CODE is an optional kill code, and PID is the process ID #.
less     Like more, but more powerful
lpq, lpstat     Get statistics on a printer(s)
lpr, lp     Print a file examples: “lpr P printer file” or “lp d printer file” lprm, cancel Cancel a print job
more     Like cat, but pauses every screen full example: “more prog.c” nohup Let a program run after you log out (NO Hang UP)
passwd      Change your password on a system
ps     Get a listing of running “processes” or programs example: “ps aux”
tail     View the beginning or ending of a file, given a number option with display that many lines
tail -25 /directory/file …    displays the last 25 lines of the file
tail -f /directory/file …    is a ‘running tail’ while updates the display as the file is written to
tar     Tape ARchive allows you to pack many files together example: “tar xvf file.tar” to extract
telnet     Open a connection on another system example: “telnet server.domain.com”
time Get runtime of a program
umask Set default file permissions (generally, do the opposite, or “777 minus what you want”)
uname Get info on a machine example: “uname -a”
uptime Get how long a machine has been up
w, who Find out who else is on a system
wc Get statistics of how many lines, words and characters in a file example: “wc file.txt”
which, whence, where File out which program you’ll be running, or where all occurrences of a program is in your path example: “which ls”

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.