2015年8月30日 星期日

Red Hat 7 chapter 6

Linux File System Permissions
 Effects of permissions on files and directories
permission effect on files   effect on directories
r(read)   contents of the file can be read    contents of the directory can by listed
w(write)   contents of the file can be changed   any file in the directory may be created or deleted
x(exec)   files can be executed as commands   contents of the directory can be accessed
special permission
u+s(suid) File executes as the user that owns the file, not the user that ran the file. No effect.
g+s(sgid) File executes as the group that owns the file.   File newly created in the directory have their  group owner set to match the group owner of the directory
o+t(sticky) No effect. Users with write on the directory can only  remove files that they own; they cannot remove or force saves to files owned by other user.

  • note that users normally have both read and exec on read-only directories , so that they can list the directory and access its contents. 
  • If a user only has read access on a directory , the names of the files in it can be listed, but no other information, including permissions or time stamps, are available , nor can they be accessed.
  • If a user only has exec access on a directory , they cannot list the names of the files in the directory, but if they already know the name of a file which they have permission to read , then they can access the contents of that file by explicitly specifying the file name.
  • A file may be removed by anyone who has write permission to the directory in which the file reside, regardless of the ownership or permissions on the file itself.
  • The command ls -l directoryname will show the expanded listing of all of the files that reside inside the directory . To prevent the descent into the directory and see the expanded listing of the directory itself.
Managing File System Permissions from the Command Line
  • The command used to change permissions from the command line is chmod, short for "change mode".
  • Symbolic method keywords
    #chmod whowhatwhich file | directory
    who is u, g, o, a(for user, group, other, all)
    what is +, -, = (for add, remove, exactly)
    which is r, w, x (for read, write, executable) 
  • Numeric method
    #chmod XXX file | directory 
    Each digit represents an access level : user, group, other.
    X is sum of r=4, w=2, and x=1.
    The chmod commands supports the -R option for recursively setting permissions on an entire directory tree.
  • File ownership can be changed with the chown command.
    The chown command can used with -R option to recursively change the ownership of an entire directory tree.
    The chown command can also be used to change group ownership of a file by preceding the group name with a colon(:).
Managing Default Permissions and File Access

Special permissions
  • The setuid permission on an executable file means that the command will run as the user(or group)of the file, not as the user that ran the command.
  • The sticky bit for a directory sets a special restriction on deletion of files: Only the owner of the file (and root) can delete files within the directory .
  • setgid on a directory means that files created in the directory will inherit the group affiliation from the directory , rather than inheriting it from the creating user.
Default file permission
  • Every process on the system has a umask, which is an octal bitmask that is used to clear the permissions of new files and directories that are created by the process.
  • The umask command  without arguments will display the current value of the shell's umask.
  • For example, the previous umask, 0002, clears the write bit for other users. The leading zeros indicate the special, user, group permission are not cleared.

2015年8月29日 星期六

Red Hat 7 chapter 5

What is a user?

  • Every process on the system runs as a particular user. Every file is owned by a particular user. Access to files and directories are restricted by user. 
  • The id command is used to show information about the current logged-in user.
  • Basic information about another user also be requested by passing in the username of that user as the first argument to the id command.
  • To view process information use the ps command.The default is to show only processes in the current shell.Add the a option to view all processes with a terminal. To view the user associated with a process , include the u option.
  • The format of /etc/passwd follows :                 username:password:UID:GID:GECOS:/home/dir:shell  
            password is where,historically,passwords were kept in an encrypted format.They are stored                 in a separate file called /etc/shadow.
            UID is a user ID, GID is the user's primary group ID number,
            GECOS field is arbitrary text,which usually includes the user's real name.
            shell is a program that runs as the user logs in.

What is a group?

  • Like users, groups have a name and number(GID). Local groups are defined in /etc/group.
  • Every user has exactly one primary group.
  • The primary group of a newly created user is a newly created group with the same name as the user. The user is the only member of this User Primary Group(UPG).
Managing Local User And Group Accounts

                   User              group
create      #useradd         #groupadd
modify     #usermod       #groupmod
remove    #userdel         #groupdel


   groupadd command -g GID option is used to specify a specify GID.
   The -r option will create a system group using a GID from the range of valid system GID number           listed in the /etc/login.defs files.
   The groupmod command is used to change a group name to a GID mapping.
   The -n option is used to specify a new name.
   The -g option is used to specify a new GID.

Usermod alters group membership

  • The membership of a group is controlled with user management.
  • Change a user's primary group with #usermod -g groupname.
  • Add a user to a supplementary group with #usermod -aG groupname username.


Red Hat 7 chapter 4

Creating  , Viewing , and Editing Text Files

Editing files with Vim

  • vim is an improved version of the vi editor distributed with Linux and UNIX systems.
  • Vim is highly configurable and efficient for practiced users , including such features as split screen editing color formatting , and highlighting for editing text.
  • An i keystroke enters insert mode , where all text typed becomes files content. Pressing Esc returns to command  mode.
  • A v keystroke enters visual mode , where multiple characters may be selected for text manipulation . Use V for multi-line and Ctrl-v for block selection . The same keystroke used to enter visual mode (v,V ,Ctrl-v)is used to exit.
  • The : keystroke begins extended command mode for tasks like writing the file to save it , and quitting the Vim editer.

Red Hat 7 chapter 3

Reading Documentation Using man Command

#man -k passwd      //the man command -k option performs a full-text page search

sections of the linux manual
section      content type
   1             User commands
   2             System calls
   3             Library functions
   4             Special files
   5             File formats
   6             Games
   7             Conventions , standards , and miscellaneous
   8             System administration and privileged command
   9             Linux kernel API

Reading Documentation Using pinfo Command

#info
#pinfo     //it adds color

Reading Documentation in /usr/share/doc

Getting Help From Red Hat

use redhat-support-tool to look up Red Hat Knowledge base articles and manage support cases.

2015年8月25日 星期二

red hat linux 7 chapter2

The Linux File System Hierarchy

/  : is the root directory at the top of the file system hierarchy
   /usr : installed software , shared libraries, include files, and static read-only program data
      /usr/bin :   User commands
      /usr/sbin :  System administration commands
      /usr/local : Locally customized software
   /etc  : Configuration files specific to this system
   /var : Variable data specific to this system that should persist between boots,
   /run : Runtime data for processed started since the last boot, This includes process ID files and lock               files, among other things.
   /home : Home directory where regular users store their personal data and configuration files
   /root : home directory for the administrative superuser, root.
   /tmp : A world-writable space for temporary files. Files which are more than 10 days old are                         deleted from this directory automatically
   /boot : Files needed in order to start the boot process.
   /dev   : Contains special device files which are used by the system to access hardware


commonly used commands

#pwd        //the pwd command displays the full path name of the current location
#ls            //the ls command lists directory contents for the specified directory
#cd           //the cd command to change directory
#touch      //the touch command normally updates a files timestamp to the current data and time                            without otherwise modifying it,This is useful for creating empty files
#ls             //the ls command has multiple options for displaying attributes on files.
                   -l(ling listing format), -a (all files, includes hidden files), -R (recursive ,to include the                            contents of all subdirectories).
#mkdir      //the mkdir command creates one or more directories or subdirectories.
                   the -p parent option creates missing parent directories for the requested destination.

2015年8月14日 星期五

red hat linux 7 chapter 1

press Ctrl + Alt + F1 to return to the first virtual console and the graphical desktop .
Ctrl + Alt + F2~F6 文字介面

shell basics

#<Command> <Options> <Argument>
       指令              參數         引數(目標)

most command have a --help option
square brackets ,[] , surround optional items
anything followed by ... represents an arbitrary-length list of items of that type
multiple items separated by pipes, | , means only one of them can be specified
text in angle brackets , <> , represents variable data

Red Hat Enteprise Linux 7 system using the GNOME 3 desktop environment to run commands form a shell prompt in a terminal program
GNOME Help  : F1   Applications > Documentation > Help     yelp command



Examples of simple commands


#data
#passwd
#file /etc/passwd 
 //the file command scans the beginning of a file's contents and displays what type it is

#head /etc/passwd   
#tail /etc/passwd
//head and tail commands display the beginning and end of a file respectively
//these commands default display  10  lines
//but have a  -n option that allows a different number of lines to be specified
#wc /etc/passwd 
//the wc command counts lines,words,and characters in a file ,and can take -l,-w,-c option


2015年8月7日 星期五

Drupal and MariaDB

安裝以下套件
MariaDB
MariaDB-bench
MariaDB-devel
MariaDB-server
MariaDB-test
php-5.4.16
php-cli
php-common
php-gd
php-mcrypt
php-mysql
php-pdo
php-theseer-fDOMDocument

https://www.phpmyadmin.net/  download  phpMyAdmin-4.4.12-all-languages.tar.gz
將phpMyAdmin-4.4.12-all-languages.tar.gz 複製到 /var/www/html目錄下解壓縮
rename to phpMyAdmin,再將資料夾內的config.sample.inc.php rename to config.inc.php
用gedit 編輯此檔案
$cfg[ 'Servers' ][$i][ 'AllowNoPassword' ] = false;    //將false改成true
$cfg[ 'blowfish_secret' ] = ' ';  //在單引號內隨便輸入幾個字
改完即可在phpMyAdmin server 用root帳號不用密碼登入


http://rpm.pbone.net/index.php3/stat/4/idpl/26646085/dir/centos_7/com/php-mbstring-5.4.16-21.el7.x86_64.rpm.html download php-mbstring-5.4.16-21.el7.x86_64.rpm and run

http://drupaltaiwan.org/  download drupal-7.38.tar.gz and drupal-7.38.zh-hant.po
將drupal-7.38.tar.gz move to /var/www/html 目錄下解壓縮
將drupal-7.38.zh-hant.po move to /var/www/html/profiles/standed/translations/
到/var/www/html/sites/default/  create files資料夾
copy default.settings.php to settings.php (同個目錄下)

#systemctl enable mariadb.service
#systemctl start mariadb.service
#cd /var/www/html/sits/default/
#chown apache.apache files
#chown apache.apache setting.php
#restorecon -R /var/www/html
#systemctl restart httpd




2015年8月5日 星期三

xrdp server 遠端桌面連線

# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux    . noarch.rpm

# yum install xrdp

#systemctl enable xrdp.server

#systemctl start xrdp.server

防火牆設定內將連接埠3389加入例外

即可用遠端桌面連線連至linux系統


Install xrdp on CentOS 7 / RHEL 7    http://www.itzgeek.com/how-tos/linux/centos-how-tos/install-xrdp-on-centos-7-rhel-7.html#axzz3hru7pXdq

IP Address config

red hat 7 ip address set
#nmtui-edit
#systemctl restart NetworkManager