Linux

From vwiki
Revision as of 13:38, 27 October 2009 by Sstrutt (talk | contribs) (Initial creation (copied from "Advanced Procedures (xTF)"))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Commands

For use in the service console

ls -l List directory contents (-l long format) - Colour codes
pwd Present working directory
cp <source> <destination> Copy a file
rm –i <file> Remove (delete) file (-i prompts before remove)
rm –d -r -f <folder> Remove (delete) folder and contents without prompting
more <file> Views a file (read only), q to exit, +line to start from line
diff <file1> <file2> Difference between two files
grep <find> <file> Find all occurrences in file
tail <file> Displays the last 10 lines of a file, -f follows any updates (eg to monitor a log file)
init <level> Level 0 - Halt system, level 6 - Reboot system
df -h Disk space summary
chmod +x <file> Add execute permission to a file
uname -a Running OS info
arp -n IP -> MAC arp table

VI Editor

VI is a bit of a pain to use, go slowly, and use [Esc] regularly to get out of the current mode after each operation

Crib sheet for VI mode commands...

i Insert characters
x Delete character
r Replace character
cw Overwrite word (use any delimiter)
o Insert line
dd Delete current line
<x>yy Yank (copy) next x lines (inclusive of current line, default x is 1)
p Paste yanked lines
/<string> Search for next occurrence of string
:g/<find>/s//<replace>/g Find and replace
:wq Write (save) and Quit
:q! Quit (don't save)
:undo Undo last action


VIM Editor

VIm = Vi Improved, the commands are the same, but theres extra features

Installation

  1. Login to the ESX console using your user account and create a new directory (within /home/user
    • mkdir vim
  2. Logon to the VCS machine (UKLONVCP1) and copy across the installation files, stored under the Software_Reposity directory (substitute user and ESXserver appropriately).
    • pscp C:\Software_Repository\vim-7.1.tar.bz2 user@ESXserver:/home/user/vim
  3. Back on the ESX console become root, change into the directory where vim is
  4. Extract the package
    • bunzip2 -c vim-7.1.tar.bz2 | tar -xf -
  5. Move into the vim71 folder
  6. Run configure
    • ./configure
  7. Compile the package
    • make
  8. Install the package
    • make install

Useful Commands

:syntax enable Turns on syntax formatting
vim one.sh two.sh three.sh Opens up three files for editing
:wnext Writes changes to existing file and moves to next file(omit w not to write)
:wprevious Writes changes to existing file and moves to previous file (omit w not to write)
v Toggle visual mode (so you can select text), use y/p to yank/paste selected text
VIM manual section 7.5 Copy text between files


Unix User accounts

  • Create Account - Use useradd <user> to add a new user account with the default policy settings
  • Modify Password - Use passwd <user> to change password for user. To breach minimum complexity rules you must be logged in at the console (in the DC not remotely)
  • Modify Expiry - To disable the password expiry policy for a account that already exists use chage -M 99999 <user> , to disable for all future account (ie modify the default policy) use esxcfg-auth --passmaxdays=99999