Fred Stluka on 31 May 2012 14:39:42 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] May Speakers? |
PLUG folks, Speaking of newbie training... I often give introductory Linux training to clients, after setting up a Linux server to host the Web apps I write for them. Appended below is the bullet list I use, as I go through various topics. The goal is to get them up to speed as a basic Linux user, and a junior sys admin, so they can do most of the ops stuff, and only call me when they get stuck. It's a bunch of reminders to me of things to mention, and links to more info at my Web site. 3 reasons for posting it here: 1. I could give a talk on some of this stuff, if there was interest. 2. Feel free to read through the list for ideas of talks you might like to give yourself. 3. Feel free to comment on things I left out or got wrong. Enjoy! --Fred ------------------------------------------------------------------------ Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. ------------------------------------------------------------------------ - Linux basics - Getting help: - man - My tips page for lots of tips about how to get help in Unix via: apropos, whatis, man, info, help, whereis, which, where, find, locate, etc. http://bristle.com/Tips/Unix.htm#help - Keys: - Ctrl-C = Cancel - Ctrl-D = End of file (easy way to exit things) - Ctrl-Z = stop (pause) job. % fg to resume % bg to resume in background - UpArrow = Command line recall - Tab = Command or file completion - Tab-Tab in bash to see multiple matches - cd, cd -, pushd, popd, pwd - mkdir, rmdir - . and .. and ~ and ~fred - ls -Fla - Permission bits: special, owner:rwx, group:rwx, world:rwx - permissions, owner, group, size, date, filename, "*@/" - chmod, chown, chgrp - umask 022 - cat - less (better than more) - h, q, space, enter, / - http://bristle.com/Tips/Unix.htm#less - head, tail, tail -f - grep -i, grep -i -r, grep -v -r or -R often means recursive - ls -Flart - touch - vi - "Visual" mode of ex, which is extended version of the original ed- Focuses on fast, portable, minimize screen updates and network traffic
- Uses no special keys. Keep fingers in typing "home position". - Only editor in the world to start in "command" mode, not insert mode, so it's easy to open a file and start typing commands accidentally. - You may prefer to use local editor and scp files to/from server. - Fred's "vi essentials" % vi filename to edit a file Arrow keys to move around in the file i to get into insert mode so you can start typing stuff, like in Windows Notepad a to get into append mode (insert mode but starting AFTER the current char, not before -- useful when you want to append to the end of a line) Enter to create a new line, when in insert mode ESC to get out of insert mode :w to save (write) your changes :q to exit vi ZZ to write and save :q! to exit w/o saving changes x delete the current char dd delete the current line :h help See also: % man vi and: http://tnerual.eriogerg.free.fr/vimqrc.pdf - cp -iv, mv -iv, rm -i -v - rm -v -R - One letter vs multi-letter options: -i, -v, -iv, --forest - alias - http://bristle.com/Tips/Unix.htm#csh_and_tcsh_aliases - .bashrc, .bash_profile, .cshrc, .kshrc, etc... - "rc" = "run commands" (.bcrc, .cshrc, /etc/rc.d etc.) - Like Windows INI file or AUTOEXEC.BAT - http://bristle.com/Tips/Unix.htm#csh_and_tcsh_startup_files - http://bristle.com/Tips/Unix.htm#sh_startup_files - http://bristle.com/Tips/Unix.htm#bash_startup_files - http://bristle.com/Tips/Unix.htm#ksh_startup_files - http://bristle.com/Tips/Unix.htm#zsh_startup_files - Unix shells - Good software design: API, CLI (shell), GUI (X-Windows) - http://bristle.com/Tips/Unix.htm#unix_shells - Windows CMD.EXE vs COMMAND.COM - Unix flavors - http://bristle.com/Tips/Unix.htm#unix_flavors - echo $var_name (e.g., echo $PATH) - Add to PATH if not there: export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin - Add ~/bin to PATH: export PATH=$PATH:~/bin - Add ~fred/bin to PATH export PATH=$PATH:~fred/bin - Add . to PATH as the very last entry (for security reasons) export PATH=$PATH:. - Fred's scripts (from ~fred/bin) % dir % except % dirr - http://bristle.com/Tips/Unix.htm#csh_script_dirr % beep - http://bristle.com/Tips/Unix.htm#csh_script_beep % loop % whichcat % whiche - More at: http://bristle.com/Tips/Unix/ - Add common folders to CDPATH: - http://bristle.com/Tips/Unix.htm#bash_set_CDPATH - Useful stuff from ~fred/.cshrc (in .bashrc format) alias del="rm" alias cp="cp -i -v" # -i = Prompt before overwriting # -v = Verbose alias mv="mv -i -v" # -i = Prompt before overwriting # -v = Verbose alias rm="rm -i -v" # -i = Prompt before removing # -v = Verbose alias ln="ln -i -v" # -i = Prompt before replacing anotheralias ps="ps -w -o user,tty,stime,ppid,pid,pgid,pri,rss,vsz,time,args"
# Show customized info about each # process. alias pstree="ps --forest" # ASCII-art tree of processes alias df="df -h" # Use suffixes GB, MB, KB, etc alias du="du -h -c" # Use suffixes GB, MB, KB, etc, w/grand # total alias dutop="du -s" # Show only top level totals, not # separate size of each subdirectory alias mkdir="mkdir -p -v" # Create parent dirs if needed, show # names of dirs created. alias md="mkdir" alias rmdir="rmdir -p -v" # Delete directory and all empty parent # directories (reverse of mkdir -p), # show names of dirs deleted. alias rd="rmdir" alias ls="ls -h --full-time --color=auto" # Use suffixes GB, MB, KB, etc # Show full date and time, not just # one or the other, when using -l. # Also shows day of week, and seconds. # Use different colors for different # file types (dirs, links, etc.) except # when piping to another command. export EDITOR="vi" export PAGER="less" export LESS="-#8 -M -j.5 -F -R -S -W -X" # -#8 = Left/right arrow scroll by # 8 chars # -m = Show percent in prompt # -M = Show percent, name, etc, in # in prompt # -N = Show line numbers # -j.5 = Searches and other jumps put # target line in middle of # screen, not at top line # Not supported on Mac OS X # -F = Quit automatically if only one # screen of text # -R = Use ANSI color escape # sequences # -S = Chop long lines (can scroll # left/right w/arrow keys) # -W = Highlight new lines and # jumped to search results # -X = Don't restore screen to # non-less contents when exiting # Otherwise, -F can cause short # files to flash on screen too # briefly to be noticed. # Also makes less work better # with windowing environments # with scrollable command line # windows. Without this option, # if you attempt to scroll back # using the native windowing # scroll mechanism, you actually # scroll back to the commands # before the less command, not # to the previous lines of the # file. - Wildcards - *.* (Windows) vs * and .* (Unix) - globbing by the shell, not by each command - ls -R - find - http://bristle.com/Tips/Unix.htm#find - Piping: - <, >, >>, |, ``, stdin/stdout/stderr, set noclobber, <<EOF, >!, >>!, >&, >>&, 2>&1 (in sh) - http://bristle.com/Tips/Unix.htm#general_command_line_redirection - sort, uniq - diff - sed, awk, tr - Spell checker: % cat file1 | tr -cs "[:alpha:]" "\n" | sort | uniq | diff - dictionary - Symbolic links: % ln -s dest source - ssh - Login for interactive session or execute remote command - scp - Same as cp, but remote like rcp, but secure - rsync - Better version of scp. - Copies only modified parts of only modified files. Very fast! - Copies local: % rsync dir1 dir2 - Copies to/from remote: %rsync dir1 fred@company1.com:dir2 %rsync fred@company1.com:dir1 dir2 - Copies between 2 remotes: %rsync fred@bristle.com:bin/dir1 joe@company2.com:bin/dir2 - Can delete files from target that are missing from source - Decades old. I wrote same thing for VAX/VMS in 1984. Still not in Windows. - tar - Linux sys admin: - yum - YellowDog Updater Modified - Same as apt-get in other Linuxes - No Windows equivalent? - Layered on top of RPM (RedHat Package Manager) - Operations: - Install, update, remove - List installed/available/all - Info about a package - etc. % man yum - /etc/... holds all system configurations - Can copy/backup via rsync/scp/cp - No Windows "registry" - /etc/rc.d holds all startup/shutdown files for services and links to them from the various run levels - All scripts in /etc/rc.d/init.d - Links in /etc/rc.d/rc[runlevel_0_thru_6].d - Invoke the init.d scripts directly to start/stop services as: % sudo /etc/init.d/sendmail [start|stop|reload|restart...] - Users, groups, passwds, rights, etc... - Users, home directories, default shells - /etc/passwd - Edit via: % sudo useradd joe_user % sudo chsh -s /bin/tcsh [joe_user] % chsh -s /bin/tcsh - Groups: - /etc/group - Encrypted passwords - /etc/shadow - /etc/gshadow - Edit via: % sudo passwd joe_user % passwd - Previous versions: - /etc/passwd- - /etc/shadow- - /etc/group- - /etc/gshadow- % groups - /etc/sudoers - Edit via: % sudo visudo - /etc/cron* holds all scheduled jobs - /etc/cron.hourly - /etc/cron.daily - /etc/cron.weekly - /etc/cron.monthly - /etc/crontab - Startup files for user logins: - /etc/csh.login - /etc/csh.cshrc - /etc/kshrc - /etc/profile - /etc/profile.d - "XXX.d" = directory of files autoloaded by XXX file - /var/log holds all log files: - System logs: boot.log, dmesg, messages - Install logs: cloud-init.log, dracut, yum.log - Security logs: secure, audit - Printer logs: cups, spooler - cron - fail2ban.log - maillog - httpd/access_log* - httpd/error_log* - tomcat6/* - View with: % less % tail -f - My *logs, *log, and *tail scripts % ls -Fla ~fred/bin - Fred's scripts (~fred/bin): % dubig - http://bristle.com/Tips/Unix.htm#csh_script_dubig % mailerrs % tripwirereview % ipblock % psgrep (better than native pgrep which shows only PIDs) - /etc/aliases holds all mail aliases and mailing lists - aliases.db generated when sendmail starts % sudo /etc/init.d/sendmail reload - /etc/fstab - List of file systems automounted at reboot - Disk usage and free space % df -h % du -h % du -s - RAM usage % free -m % vmstat - Processes, ports, etc - Ports typically used: - /etc/services - Ports currently in use % netstat -n -a --program - Processes currently running: % ps -A -w -o user,tty,stime,ppid,pid,pgid,pri,rss,vsz,time,args - Fred's psgrep - Kill process % kill [-9] PID % killall - Kills by name instead PID- Processes currently running (interactive -- like Windows Task Manager)
% top h = Help q = Quit z = Colors B = Bold numbers in header rows d1 = Delay = 1 sec, not 3 secs c = Show command H = Show threads x = Highlight sort column y = Highlight running tasks (eligible to run) b = Bold highlighted stuff, instead of reverse video i = Hide/show idle processes S = Cumulative time (parent and dead child processes) f = Add/remove columns o = Reorder columns F = Column to sort rows by O = Column to sort rows by (same as F) > = Sort by field to the right of the current sort field < = Sort by field to the left of the current sort field R = Sort in reverse order A = Show multiple, separately configurable windows Z = Change colors W = Save settings in ~/.toprc for future sessions k = kill (prompts for process PID) % top -U user_name % top -p process_id - Time since last reboot % uptime - Users logged in % finger % users % id % who % who am i % whoami % w Other Linux commands from: http://www.itworld.com/sites/default/files/UbuntuUnleashed2012_Helmke_ch10.pdf - Managing users and groups - chage, chfn, chsh, edquota, gpasswd, groupadd, groupdel, groupmod, groups, mkpasswd, newgrp, newusers, passwd, umask, useradd, userdel, usermod - Managing files and file systems - cat, cd, chattr, chmod, chown, compress, cp, dd, fdisk, find, gzip, ln, mkdir, mksfs, mount, mv, rm, rmdir, rpm, sort, swapon, swapoff, tar, touch, umount, uncompress, uniq, unzip, zip - Managing running programs - bg, fg, kill, killall, nice, ps, pstree, renice, top, watch - Getting information - apropos, cal, cat, cmp, date, diff, df, dir, dmesg, du, env, file, free, grep, head, info, last, less, locate, ls, lsattr, man, more, pinfo, ps, pwd, stat, strings, tac, tail, top, uname, uptime, vdir, vmstat, w, wc, whatis, whereis, which, who, whoami - Console text editors - ed, jed, joe, mcedit, nano, red, sed, vim - Console Internet and network commands - bing, elm, ftp, host, hostname, ifconfig, links, lynx, mail, mutt, ncftp, netconfig, netstat, pine, ping, pump, rdate, route, scp, sftp, ssh, tcpdump, traceroute, whois, wire-test On 5/31/12 1:55 PM, Rich Freeman wrote:
On Thu, May 31, 2012 at 4:47 AM, Sam Gleske<sam.mxracer@gmail.com> wrote:As far as meeting topics go I can cover a variety of topics. Bash Introduction: vim Introduction:I liked a bunch of topics on your list, but I wanted to call attention to your most basic ones. I'll admit that both of these would be snoozers for me (well, I'd likely catch on to a few new things). However, every other meeting it seems like we have a few new people, and since most of us are seasoned they likely struggle to keep up. Would it make sense to try to fit in some newbie-oriented content every once in a while? Maybe it shouldn't be the sole topic of the night, but perhaps every other meeting we might cut short discussion by 15min and have somebody present more fundamental material before the main talk. Perhaps we might even keep a deck of standard materials handy and just have somebody wing this presentation if there are newbies in the audience, and skip it if not. It is hard to plan for whether there are new people around, so I'd hate to see people travel to give a presentation on bash 101 and find that everybody has been using linux for 10 years. Any thoughts here? We might hang onto newcomers with a broader approach, but I don't want to become irrelevant for the majority of seasoned participants either. Rich ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug