User Tools

Site Tools


mywiki:linux:linuxadmin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mywiki:linux:linuxadmin [2015/02/02 09:09] shaoguohmywiki:linux:linuxadmin [2019/09/15 18:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
-Linux Admin+Linux Admin  
 +| Reference | [[http://www.er.uqam.ca/nobel/r10735/unixcomm.html|Useful Linux Commands]] | [[SSH]] |
  
-====== Add User to groups ======+====== Schedule routine with crone ====== 
 +Linux cron utility is an effective way to schedule a routine background job at a specific time and/or day on an on-going basis.
  
-For example, add user jerry to groups ftp, www_data:+| Display all scheduled routine  | crontab -l | 
 +| Add a scheduled routine | crontab -e |
  
-useradd -G ftp,www_data jerry+Routine Format Example:  
 +0 4 * * * /opt/comlab/users/shaoguoh/bin/update_outpost_repo.sh https://mts.lantiq.com/~wlnsw/repo/project/ugw /tmp2/shaoguoh/project/ugw.clone_only
  
-====== Shorthand at the Command Prompt ======    +By the way, first 5 digits means: MIN HOUR DOM MON DOW CMD 
 + 
 +    0 – 0th Minute 
 +    04 – 04 AM 
 +    * – every day 
 +    * – every month 
 +    * – Every day of the week 
 + 
 +====== User groups management ====== 
 +| Set user to a primary group list only | usermod -G groups username 
 +| Add user to other groups based on current groups | usermod -aG additional_groups username | 
 +| Display user's groups | groups username | 
 + 
 +====== how to know current shell ====== 
 +  * echo $0 - will print the program name... which in the case of shell is the actual shell 
 +  * ps -ef | grep $$ | grep -v grep - will look for current process ID in the list of running processes. Current process being shell, it will include shell. This is not 100% reliable  
 +  * echo $SHELL The path to the current shell is in SHELL variable for any shell. it seems not reliable ?? 
 + 
 + 
 + 
 +====== Shorthand at the Command Prompt ======
   * / :  root directory    * / :  root directory 
   * ./ :  current directory    * ./ :  current directory 
Line 39: Line 63:
   * [Leftmousebutton] :  Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode.    * [Leftmousebutton] :  Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode. 
   * [Middlemousebutton] :  Copies text from the text buffer and inserts it at the cursor location. With a two: button mouse, click on both buttons simultaneously. It is necessary for three: button emulation to be enabled, either under gpm or in XF86Config.    * [Middlemousebutton] :  Copies text from the text buffer and inserts it at the cursor location. With a two: button mouse, click on both buttons simultaneously. It is necessary for three: button emulation to be enabled, either under gpm or in XF86Config. 
 +
 +
 +====== Typical Dot Files(.*) ======
 +  * .bash_logout - file executed by bash shell on logout 
 +  * .bash_profile - initialization of bash shell run only on login. Bash looks first for a .bash_profile file when started as a login shell or with the -login option. If it does not find .bash_profile, it looks for .bash_login. If it doesn't find that, it looks for .profile. System-wide functions and aliases go in /etc/bashrc and default environment variables go in /etc/profile. 
 +  * .bashrc - initialization command run when bash shell starts up as a non-login shell 
 +  * .cshrc - initialization commands that are run automatically (like autoexec.bat) when C shell is initiated 
 +  * .emacs - configuration file for emacs editor 
 +  * .fvwmrc - configuration file for fvwm window manager 
 +  * .fvwm2rc - configuration file for fvwm2 window manager 
 +  * .jedrc - configuration file for the jed text editor 
 +  * .lessrc - typically contains key bindings for cursor movement with the less command 
 +  * .login - initialization file when user logs in 
 +  * .logout - commands run when user logs out 
 +  * .wm_style - gives choice of default window manager if one is not specified in startx 
 +  * .Xdefaults - sets up X resources for individual user. The behavior of many different application programs can be changed by modifying this file. 
 +  * .xinitrc - initialization file when running startx. Can be used to activate applications, run a given window manager, and modify the appearance of the root window. 
 +  * .xsession - configuration file for xdm 
 +
 +
 +====== Useful Files ======
 +  * /etc/bashrc : system-wide default functions and aliases for the bash shell 
 +  * /etc/crontab : shell script to run different commands periodically (hourly, daily, weekly, monthly, etc.) 
 +  * /etc/fstab : contains information on partitions and filesystems used by system to mount different partitions and devices on the directory tree 
 +  * /boot/vmlinuz : the typical location and name of the Linux kernel. In the Slackware distribution, the kernel is located at /vmlinuz. 
 +  * /dev/fd0 : first floppy disk drive 
 +  * /dev/fd0H1440 : driver for the first floppy drive in high density mode. Generally, this is invoked when formatting a floppy drive for a particular density. Slackware comes with drivers that allow for formatting a 3.5" diskette with up to 1.7MB of space. Red Hat and Mandrake do not contain these device driver files by default. 
 +  * /dev/fd1 : second floppy disk drive 
 +  * /dev/hda : first IDE hard drive 
 +  * /dev/hdc : on many machines, the IDE cdrom drive. Most often, there is a symbolic link called /dev/cdrom which is just a link to the true cdrom driver file. 
 +  * /dev/null : used when you want to send output into oblivion 
 +  * /etc/aliases : file containing aliases used by sendmail and other MTAs (mail transport agents). After updating this file, it is necessary to run the newaliases utility for the changes to be passed to sendmail. 
 +  * /etc/conf.modules : aliases and options for configurable modules 
 +  * /etc/DIR_COLORS : used to store colors for different file types when using ls command. The dircolors command uses this file when there is not a .dir_colors file in the user's home directory. Used in conjunction with the eval command (see below). 
 +  * /etc/exports : specifies hosts to which file systems can be exported using NFS. Man exports contains information on how to set up this file for remote users. 
 +  * /etc/HOSTNAME : stores the name of the host computer 
 +  * /etc/hosts : contains a list of host names and absolute IP addresses. 
 +  * /etc/hosts.allow : hosts allowed (by the tcpd daemon) to access Internet services 
 +  * /etc/hosts.deny : hosts forbidden (by the tcpd daemon) to access Internet services 
 +  * /etc/group : similar to /etc/passwd but for groups 
 +  * /etc/inetd.conf : configures the inetd daemon to tell it what TCP/IP services to provide (which daemons to load at boot time). A good start to securing a Linux box is to turn off these services unless they are necessary. 
 +  * /etc/inittab : runs different programs and processes on startup. This is typically the program which is responsible for, among other things, setting the default runlevel, running the rc.sysinit script contained in /etc/rc.d, setting up virtual login terminals, bringing down the system in an orderly fashion in response to [Ctrl][Alt][Del], running the rc script in /etc/rc.d, and running xdm for a graphical login prompt (only if the default runlevel is set for a graphical login). 
 +  * /etc/issue : pre-login message. This is often overwitten by the /etc/rc.d/rc.S script (in Slackware) or by the /etc/rc.d/rc.local script (in Mandrake and Red Hat, and perhaps other rpm-based distributions). The relevant lines should be commented out (or changed) in these scripts if a custom pre-login message is desired. 
 +  * /etc/lilo.conf : configuration file for lilo boot loader 
 +  * /etc/motd : message of the day file, printed immediately after login. This is often overwritten by /etc/rc.d/rc.S (Slackware) or /etc/rc.d/rc.local (Mandrake/Red Hat) on startup. See the remarks in connection with /etc/issue. 
 +  * /etc/mtab : shows currently mounted devices and partitions and their status 
 +  * /etc/passwd : contains passwords and other information concerning users who are registered to use the system. For obvious security reasons, this is readable only by root. It can be modified by root directly, but it is preferable to use a configuration utility such as passwd to make the changes. A corrupt /etc/passwd file can easily render a Linux box unusable. 
 +  * /etc/printcap : shows the setup of printers 
 +  * /etc/profile : sets system-wide defaults for bash shell. It is this file in Slackware that sets up the DIR_COLORS environment variable for the color ls command. Also sets up other system-wide environment variables. 
 +  * /etc/resolv.conf : contains a list of domain name servers used by the local machine 
 +  * /etc/securetty : contains a list of terminals on which root can login. For security reasons, this should not include dialup terminals. 
 +  * /etc/termcap : ASCII database defining the capabilities and characteristics of different consoles, terminals, and printers 
 +  * /etc/X11/XF86Config : X configuration file. The location in Slackware is /etc/XF86Config. 
 +  * /proc/cpuinfo : cpu information 
 +  * /proc/filesystems : prints filesystems currently in use 
 +  * /proc/interrupts : prints interrupts currently in use 
 +  * /proc/ioports : contains a list of the i/o addresses used by various devices connected to the computer 
 +  * /proc/kcore : The command ls -l /proc/kcore will give the amount of RAM on the computer. It's also possible to use the free command to get the same information (and more). 
 +  * /proc/version : prints Linux version and other info 
 +  * /var/log/messages : used by syslog daemon to store kernel boot-time messages 
 +  * /var/log/lastlog : used by system to store information about last boot 
 +  * /var/log/wtmp : contains binary data indicating login times and duration for each user on system 
   *    * 
 +
mywiki/linux/linuxadmin.1422839357.txt.gz · Last modified: (external edit)