Code University

      "Where tuition is free!"

News | Images | Contact     
  • Home
  • Coding KC
  • Scripts
  • Software
  • Templates
  • Tutorials
  • About
 

Coding Knowledge Center

Linux/Unix


Page Contents
[X] CLOSE

Administration

  • Administration (visudo)

apropos

  • apropos

cat

  • cat

cut

  • cut

IRC

  • IRC (Irssi - commands)

man

  • man

Permissions

  • Permissions (01. Example)
  • Permissions (02. File type codes - bit 1)
  • Permissions (03. bit codes - bits 2-10)
  • Permissions (04. bit groupings)
  • Permissions (05. SUID - bit 4)
  • Permissions (06. SGID - bit 7)
  • Permissions (07. Sticky Bit - bit 10)
  • Permissions (08. chmod)
  • Permissions (09. chmod - find)
  • Permissions (10. chown)

Redirection

  • Redirection (operators)

Snippet

  • Snippet (find)

Snippets

  • Snippets (arch)
  • Snippets (bc)
  • Snippets (echo)
  • Snippets (id)
  • Snippets (kill)
  • Snippets (rsync)

VI

  • VI (Commands)
  • VI (Files)
  • VI (Modes)
  • VI (Settings)

VIM

  • VIM (settings - vimrc)
Toggle Page Contents
Administration (visudo)Copy  To New Window  Top ^
visudo (edit /etc/sudoers) # /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # See the man page for details on how to write a sudoers file. # Defaults env_reset # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL) ALL steved ALL=(ALL) ALL %admin ALL=(ALL) ALL
Add users you'd like to have sudo access. Add groups prefixed w/ a % sign.



aproposCopy  To New Window  Top ^
> apropos print
Searches through man pages for relavent topics regarding the word print.



catCopy  To New Window  Top ^
> cat > file.txt
Creates the file named "file.txt" and accepts the following lines as file contents. Press CTRL+d to exit data entry.



cutCopy  To New Window  Top ^
> cut -d: -f5 file.txt
Cuts data from the fifth field a colon delimited file.



IRC (Irssi - commands)Copy  To New Window  Top ^
esc, n - Scroll screen up (do for each scroll needed) esc, p - Scroll screen down (do for each scroll needed) ALT + # - Switches to window with respective number.
Irssi Commands



manCopy  To New Window  Top ^
1) man -k list 2) man -S 5 passwd
1) Searches man pages for references to 'list'. Also see the 'apropos' command. 2) Displays the fifth man page section for the passwd command.



Permissions (01. Example)Copy  To New Window  Top ^
A) ---------- : file with all access denied B) drwxrwxrwx : directory with all access allowed C) ---------- 1234567890
Example A shows a file's permissions with all access denied. Example B shows a directory's permission with all access allowed Example C lays out each bit with a number underneath for reference in the following descriptions.



Permissions (02. File type codes - bit 1)Copy  To New Window  Top ^
- - normal file d - directory l - symbolic link p - named pipe s - socket b - block device c - character device
The first permission bit of a file is represented with one of the above characters and designates the inode type.



Permissions (03. bit codes - bits 2-10)Copy  To New Window  Top ^
r = 4 (read) w = 2 (write) x = 1 (execute) - = 0 (no permissions)
Each permission type is assigned a value 4, 2, 1 or 0



Permissions (04. bit groupings)Copy  To New Window  Top ^
user : -rwx------ (bits 2-4) group : ----rwx--- (bits 5-7) other : -------rwx (bits 8-10)
The first permission bit (indicated by 1) is represented with one of the above characters and designates the inode type.



Permissions (05. SUID - bit 4)Copy  To New Window  Top ^
s - suid code w/ user execute permissions -rwsrwxrwx S - suid code w/o user execute permissions -rwSrwxrwx
Sometimes it necessary to run a program as the owner of the program. Setting the SUID gives the ability to setup a program to be run as if the owner were running it. A lower case "s" indicates that the owner has executable permissions as well. An uppercase "S" implies the the user does not have executable permissions.



Permissions (06. SGID - bit 7)Copy  To New Window  Top ^
s - sgid code w/ group execute permissions -rwxrwsrwx S - sgid code w/o group execute permissions -rwxrwSrwx
Sometimes it necessary to run a program as the group who owns the program. Setting the SGID gives the ability to setup a program to be run as if the group owner were running it. A lower case "s" indicates that the group has executable permissions as well. An uppercase "S" implies the the group does not have executable permissions.



Permissions (07. Sticky Bit - bit 10)Copy  To New Window  Top ^
t/T - sticky bit -rwxrwxrwt -rwxrwxrwT
The first permission bit (indicated by 1) is represented with one of the above characters and designates the inode type.



Permissions (08. chmod)Copy  To New Window  Top ^
chmod 777 file1 OR chmod ugo+rwx file1
Here are two different ways to perform the same permission change.



Permissions (09. chmod - find)Copy  To New Window  Top ^
1) find ./ -user steved -type f -print | xargs chmod 666 find ./ -user steved -type d -print -exec chmod 666 {} \; 2) find ./ -user steved -type d -print | xargs chmod 777 find ./ -user steved -type d -print -exec chmod 777 {} \;
1) These commands find all of the files, in the present working directory, owned by steved and changes their permissions to 666. Both commands do the same thing. 2) These commands find all of the directories, in the present working directory, owned by steved and changes their permissions to 777. Both commands do the same thing.



Permissions (10. chown)Copy  To New Window  Top ^
1) chown steved file1 2) find ./ -user root | xargs chown steved
1) This command changes ownership of the file "file1" to steved. 2) This command finds all of the nodes, in the present working directory, owned by root and changes their ownership to the user steved.



Redirection (operators)Copy  To New Window  Top ^
- Creates a new file containing standard output. If the file exists then its overwritten. >> - Appends standard output to the file. If the file does not exist it is created. 2> - Creates a new file containing standard error. If the file exists then its overwritten. 2>> - Appends standard error to the file. If the file does not exist it is created. &> - Creates a new file containing both standard output and standard error. If the file exists then its overwritten. < - Uses the contents of the specified file as standard input to the receiving program. << - Uses the contents of the following lines as standard input to the receiving program. <> - Uses the contents of the specified file as standard input and standard output.
Operators used in redirection statements.



Snippet (find)Copy  To New Window  Top ^
find . -type d -exec chmod 775 {} \; find . -type f -exec chmod 664 {} \; find . -user root | xargs chown steved find /usr/local/src -exec grep -s "mytext" {} \; -exec echo " " {} "\n" \;
Various find commands



Snippets (arch)Copy  To New Window  Top ^
> arch i386
Various arch commands



Snippets (bc)Copy  To New Window  Top ^
bc -l
Various bc commands



Snippets (echo)Copy  To New Window  Top ^
> echo {con,pre}{sent,fer}{s,ed} consents consented confers confered presents presented prefers prefered
Various echo commands



Snippets (id)Copy  To New Window  Top ^
> id uid=501(steved) gid=20(staff) groups=20(staff),98(_lpadmin),81(_appserveradm), 101(com.apple.sharepoint.group.1),79(_appserverusr),80(admin)
Various id commands



Snippets (kill)Copy  To New Window  Top ^
killall -HUP inetd kill -stop PID kill -cont PID
Various kill commands



Snippets (rsync)Copy  To New Window  Top ^
rsync -avz --no-perms /the/original/path/subdir -e ssh login@server:/the/original/path
Various rsync commands



VI (Commands)Copy  To New Window  Top ^
Commands: k - up j - down h - left l - right ^ - beginning of line $ - end of line 1G OR :0 - goto start of file G OR :$ - goto end of file nG - goto line # a - append here A - append at end of line J - join 2 lines i - insert here I - insert at start of line R - overstrike o - open line below current line O - open line above current line p - put yanked line below current line u - undeo last change U - undo all changes x - delete character yy - yank line :%s/str1/str2/g - substitute string str1 to string str2 globally /pattern - search pattern n - repeat previous search N - repeat previous search in reverse n1,n2tn3 - copy lines from line n1-n2 and put after line n3 n1,n2mn3 - move lines from line n1-n2 and put after line n3 :q - quit :q! - quit w/o save :x OR :wq - save & quit
VI Commands



VI (Files)Copy  To New Window  Top ^
~/.exrc ~/.vimrc
Files used for vi settings.



VI (Modes)Copy  To New Window  Top ^
insert mode command mode ex mode
VI modes.



VI (Settings)Copy  To New Window  Top ^
:set number - turns on line numbering :set nonumber - turns off line numbering
Command mode settings.



VIM (settings - vimrc)Copy  To New Window  Top ^
autocmd BufReadPost * // open at last line
Configures vim to open files at the last line it was on before closed.
Technologies
  • Introduction
  • Awk
  • Bash
  • Cron
  • CSH
  • CSS
  • CVS
  • FTP
  • FTPS
  • HTML
  • JavaScript
  • KSH
  • Linux
  • Linux (Debian)
  • Linux (LPIC 101-102)
  • Linux/Unix
  • Mac OS X
  • MySQL
  • Oracle
  • Perl
  • PGP
  • PHP
  • Sed
  • SQLite
  • SSH/SCP/SFTP
  • Telnet
  • UNIX
  • Windows
Resources
  • CodeIgniter - MVC Framework
  • HowtoForge - Linux Tutorials
  • Linux Today - Linux News
  • Lxer - Linux News Feed
  • Monsterb - Linux, Podcasting
  • MySQL - Databasing
  • Perl - Programming
  • PHP - Programming
  • Systhread - Admin & Programming
  • W3Schools - Web Tutorials
About

Code University contains a wealth of technical information aimed at the computer sciences.


 
Home | Coding KC | Scripts | Software | Templates | Tutorials | About
Top ^
 
© 2007-2012 Code University| Disclaimer
Website template by Arcsin