Official Site

click here to view our new site launched

Pages

Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Thursday, March 21, 2013

Command Line Mac Os

On Mac OS X (and Linux), vi is symlinked to vim (vi improved), a more modern free software version. Vim It is the default editor when changing a crontab.

Vi has two modes, command and insert (really, three if you count replace mode). Command mode is used to navigate, search, and issue other commands. Insert mode is used to enter text.

While in command mode (case sensitive)

move the cursor with arrow keys; if there aren't any arrow keys, use j,k,h,l

i - change to insert mode (before cursor)
a - change to insert mode (after cursor)
A - change to insert mode (at end of line)
r - replace one character
R - overwrite text
x - delete one character
dd - delete one line
yy - yank line (copy)
p - paste deleted or yanked text after cursor
P - paste deleted or yanked text before cursor
G - go to end of the file
1G - go to top of the file
J - merge next line with this one
/ - search, follow / with text to find
:wq - write file and quit
:q! - quit without saving
%s/old/new/g - substitute; replace "old" with "new" on all lines
:g/pattern/d - delete all lines that match the pattern

While in insert mode

ESC - change to command mode
any text typed is entered at the cursor

Typical vi session

Type "vi file.txt" at command prompt
Move cursor to where new text will be added
Type "i" to change to insert mode
Type new text
Type ESC to go back to command mode
type ":wq" and ENTER to write the file and quit



Support us at Sync4Brain

Sunday, February 24, 2013

File Permissions Made Easy - Command Line

Checking File Permission

ls -lart filename
or
ls -l filename

The file permissions can be displayed using the command:
% ls -l [filename]
For example, to display the permissions on the file myfile.txt, type the command:
% ls -l myfile.txt
-rw-r--r-- 1  lnp5jb  777  Dec 22  myfile.txt

Changing File Permissions

The easiest way is the symbolic method, which lets you specify access classes and types with single letter abbreviations.

chmod modes

In the command:
% chmod mode filename
the mode consists of three elements:
who
operator
permissions
The following options are possible:

who:

u user (owner)
g group
o other
a all

operators:

- remove permission
+ add permission
= assign permission

permissions:

r read
w write
x execute


For example:

  • to add permission for everyone to read a file in the current directory named myfile, at the Terminal , The  stands for "all", the  +  for "add", and the  r  for "read". you would enter: 
    • chmod a+r myfile
  • removes read and write permissions from others.
    • chmod o-rw file1.f
  • adds execute permission to the owner.
    • chmod u+x test
$2.49 .COM at GoDaddy.com! Expires 5/14/13