Archive for the 'Commands I should remember' Category
setuid/sgid
How Unix works is, when a user creates a file, the file’s group is the user’s, which means other users could not edit it. So my developers and I always had this problem, and I always had to use “chown -R www-data:www-data . ” to change all the groups of the files in the current directory, but there’s a better way. You can set up setuid.
$ chgrp ftpusers /path/to/the/ftp/directory
$ chmod g+s $_
More information: http://www.cyberciti.biz/faq/unix-bsd-linux-setuid-file/
No commentsUnix $_
$_ is a variable that holds the last argument in the last command. For example,
$ chgrp ftpusers /path/
$ chmod g+s $_
$_ would equal the path. You can also echo $_ and experiment around.
No commentsvi: copying lines to another file
You should yank the text to the * or + registers:
gg"*yG
Explanation:
gg- gets the cursor to the first character of the file
"*y- Starts a yank command to the register
*from the first line, until…
- Starts a yank command to the register
G- go the end of the file
http://stackoverflow.com/questions/1620018/vi-editor-copy-all-the-lines-to-clipboard
- Edit the first file, yanking the text you want. Then open your second file from within vi (
:e /path/to/other/file) and paste it -
Open both files together in a split window and navigate between them using Ctrl + w,Up/Down either by:
vi -o /path/to/file1 /path/to/file2- From within the first file, Ctrl + w, s
http://stackoverflow.com/questions/4620672/copy-and-paste-content-from-one-file-to-another-file-in-vi
No commentsvi: Show recent command history
You can show the last few commands used in vi by typing q:
:q is for quitting, while q: is for recent commands.
No commentsMoving “dot” files
When moving dot files with a asterisk, the asterisk does not include the dot files unless you turn on “dotglob”.
To turn on (setting the option):
shopt -s dotglob
To turn off (unsetting the option):
shopt -u dotglob
No comments