Editing Sudoers, what are the options?


 
Thread Tools Search this Thread
Special Forums Cybersecurity Editing Sudoers, what are the options?
# 1  
Old 08-17-2012
Data Editing Sudoers, what are the options?

Hi,

I am confused about editing Sudoers file as what to write and what not to? Can you please help me?

I am trying to edit Sudoers for running few commands like copying, moving, listing, searching, creating, changing permissions on files and directories in the home directory for user e.g. a test user but i am not sure how to restrict the user action to a particular directory or restrict the commands all other commands except ls, cp, grep, wc, cat, touch, chmod, chown running at root level (e.g. rm -r command)? What would be the syntax?

Thank you in advance.

Shahmeer
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Sudoers

Having a bit of a discussion with a software vendor about this. Can anyone confirm my understanding? /etc/sudoers file example:- user1 server1 = NOPASSWD:/usr/bin/ls -l user1 server1 = NOPASSWD:/usr/bin/file But then the following command fails (logged in on server 1 as user1) because... (2 Replies)
Discussion started by: psychocandy
2 Replies

2. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies

3. Ubuntu

Kernel boot options removed by fault, no boot options

Hello Everyone, First of all, I highly appreciate all Linux forum members and whole Linux community. http://forums.linuxmint.com/images/smilies/icon_wink.gif. I wish you the best for all of you ! I will try to be short and concise: I am using Linux Mint 10 for 2 months on 2 ws, and all went... (3 Replies)
Discussion started by: cdt
3 Replies

4. Solaris

sudoers

what is the configuration file for sudo? can we edit it as like other file or will it create any adverse effect on editing that file? thanks in advance dinu (1 Reply)
Discussion started by: dinu
1 Replies

5. Solaris

sudoers

this is for the first time i am going to use sudoers i want know how to create sudoers and giving privileges for that users thanks in advance dinu (6 Replies)
Discussion started by: dinu
6 Replies

6. UNIX for Advanced & Expert Users

sudoers file

i have defined a rule in the sudoers file so a specific user is able to run some commands as sudo with no password. my question is: is it possible to restrict a user to run commands as sudo only in a certain directory? for example: chown only the files that are located in /var/tmp. Thank you. ... (2 Replies)
Discussion started by: noam128
2 Replies

7. UNIX for Dummies Questions & Answers

sudoers

i just installed/configured apache2.0 on my own aix5.3 mini server. i can start/stop apache by root, but i want to start it under my login id(admin) instead. i need to execute this command: /usr/bin/sudo /usr/IBM/HTTPServer/bin/apachectl stop/start. (5 Replies)
Discussion started by: tjmannonline
5 Replies

8. UNIX for Dummies Questions & Answers

sudoers on HP 11.11

Having a "running low on coffee" moment here & need help. On HP 11.11 where is the sudoers file located; I looked every place I could think of and don't see it. Thanks in advance:confused: (2 Replies)
Discussion started by: dhlopomo
2 Replies
Login or Register to Ask a Question
edit(1) 						      General Commands Manual							   edit(1)

NAME
edit - Edits a file line by line with a simplified command set SYNOPSIS
edit [-c subcommand] [-lRv] [-wnumber] [+subcommand] [-] [file...] edit [-c subcommand] [-lRv] [-t tag] [file...] edit [-c subcommand] -r[file] [-lRv] [file] The edit command provides a line editor designed for beginning users. OPTIONS
Indents appropriately for LISP code, and accepts the (, ), {, }, [, and ] characters (parentheses, braces, and brackets) as text rather than interpreting them as vi subcommands. The LISP modifier is active in open or visual modes. Recovers file after an editor or system crash. If you do not specify file, a list of all saved files is displayed. Sets the readonly option, preventing you from altering the file. Loads the file that contains tag and positions the editor at tag. To use this option, you must first create a database of function names and locations using the ctags command. Invokes the visual editor. When the -v option is specified, an enlarged set of subcommands are available, including screen editing and cursor movement features. See vi. Sets the default window size to number lines. Suppresses all interactive user feedback. If you use this option, file input/output errors do not generate an error message. Begins the edit with the specified editor search or subcommand. When subcommand is not entered, a + (plus sign) sets the current line to the bottom of the file. Normally edit sets the current line to the last line of the file, or to some specified tag or pattern. DESCRIPTION
The edit command is part of a family of editors that also includes ed, ex, and vi. It is a simplified version of the ex editor, which itself is built on the ed line editor. To edit the contents of a file, enter: edit file If file is the name of an existing file, edit copies it to a buffer and displays the number of lines and characters in it. Then it dis- plays a : (colon) prompt to show that it is ready to read subcommands from standard input. If file does not already exist, edit tells you this. You can give more than one file, in which case edit copies the first file into its buffer and stores the remaining filenames in an argument list for later use. The edit command does not make changes to the file until you use the w subcommand to write the changes. Editing Modes The edit command operates in one of two modes: In command mode, the edit editor recognizes and executes subcommands. When you start the editor, it is in command mode. In text input mode, you can add text to the editing buffer. You enter text input mode by using the a, c, or i subcommand. To exit text input mode (and return to command mode), you enter a (dot) alone at the beginning of a line. Subcommand Syntax The general format of an edit subcommand is as follows: [address]subcommand[argument ...][count] If you do not specify an address, edit works on the current line. When you start the edit program, the current line is the last line in the buffer. As you edit the buffer, the current line changes to the last line affected by a subcommand. (When edit reads a file into its buffer, the last line affected by the process of reading is the last line in the file.) If you add a numeric count to most subcommands, edit works on the specified number of lines. The value for address can be a line number or a pattern to be matched or, in some cases, a range of line numbers or patterns. To specify a range, separate two line numbers or patterns with a comma or a semicolon (for example, 1,5 or 1;5). In a range, the second address must refer to a line that follows the first addressed line in the range. To work with different parts of a file, you must know how to find out the current line and how to address different lines in a file. Addressing Lines Within a File The simplest way to address a line within a file is to use its line number. But this can be unreliable because line numbers change when you insert and delete lines. The edit command provides a way to search through the buffer for strings. Given the following address, edit searches forward for pattern: /pattern/ If given the following address, edit searches backward for pattern: ?pattern? If a forward search reaches the end of the buffer without finding pattern, it continues the search at the beginning of the file until it reaches the current line. A backward search does just the reverse. The following characters have special meanings in these search patterns: Matches the beginning of a line. Matches the end of a line. Thus, you can use /^pattern/ to search for patterns at the beginning of a line, and /pattern$/ to search for patterns at the end of the line. Lines can be addressed by their line numbers; for example, 11 refers to line 11 of the buffer. In addition, the current line is addressed with a (dot) and the last line in the buffer is addressed with a $ (dollar sign). This is useful when working with a range of lines. For example, the following command displays all lines from the current line to the last line in the buffer: .,$print Do not confuse the meaning of $ in text patterns, end of line, with its meaning in addresses, last line. Arithmetic with line references is also possible, so that $-5 refers to the fifth line from the last and refers to the line 20 lines past the current line. You can also use the = (equal sign) command to find out the line number of the current line or the last line, as follows: .= $= To view the next line in the buffer, press <Return>. Press <Ctrl-d> to display the next half-screen of lines. Using a Family of Editors As you become more experienced with edit, you might want to try the advanced features of one of the other editors in the family. Because edit is part of a family of editors, you can apply your knowledge of edit to the other editors in the family. The ex editor is a powerful interactive line editor. The edit subcommands work the same way in ex, but the editing environment is somewhat different. For example in edit, only the characters ^ (circumflex), $ (dollar sign), and (backslash) have special meanings as pattern- matching characters; however, several additional characters also have special meanings in ex. SUBCOMMANDS
Unless otherwise noted, all subcommands work by default on the current line; address is optional. You can use the full subcommand or its abbreviation. Subcommand abbreviations appear after the command in the sections that follow. You can use the 1,$p subcommand to display the entire contents of the buffer. The edit program recognizes and interprets the following subcommands when it displays the colon prompt. Adding Text Appends the text you type after the current line, if you do not specify an address. If you specify an address, the a subcommand appends text after the addressed line. If you specify address 0 (zero), the a subcommand places the text at the beginning of the buffer. As you type your text, press <Return> at the end of each line. When you have entered all your text, enter a (dot) alone at the start of a line. This ends text input mode and returns to command mode. Places the given text before the specified line. Enter a (dot) to return to com- mand mode. The last line input becomes the current line. Changing Text Replaces the current line or addressed line or lines with the input text. Enter a (dot) to return to command mode. If any lines are input, the last input line becomes the new current line. Deleting Text Removes the specified line or lines from the editing buffer. The line following the last deleted line becomes the current line. If you specify a buffer by giving a letter from a to z, edit saves the specified lines in that buffer or, if the letter is uppercase, appends the lines to that buffer. Displaying Text and Determining the Current Line Displays the current filename along with the following information: Whether it was modified since the last write. What the current line is. How many lines are in the buffer. What percentage of the way through the buffer the current line is. Also, sets the current filename if file is specified. Displays each specified line or lines preceded by its buffer line number. The last line displayed becomes the current line. Displays the specified line or lines. The last line displayed becomes the cur- rent line. Displays the line number of the addressed line. If you do not specify an address, displays the line number of the last line. Displays a screen of text, beginning with the current or specified line. Displays a screen of text, with the specified (or current) line at the bottom of the screen. Displays a screen of text, with the specified (or current) line in the middle of the screen. Editing Another File Begins an editing session on a new file. The editor first checks to see if the buffer was modified since the last write subcommand. If it has, edit issues a warning and cancels the edit subcommand. Otherwise, it deletes the complete contents of the editor buffer, makes the named file the current file, and displays the new filename. After ensuring that this file can be edited, it reads the file into its buf- fer. If edit reads the file without error, it displays the number of lines and characters that it read. The last line read becomes the new current line. Copies the next file in the command line argument list to the buffer for editing. You can edit a sequence or group of files. You can use the next subcommand to edit each file on the command line in turn, or to specify a list of filenames to edit (using the shell pattern matching syntax) instead. The wildcard character % represents the name of the current edit file and can be used to form filenames. If file is specified, the command line argument list is replaced, and an edit command is performed on the first file. Making Global Changes Marks each of the specified lines that matches the pattern, then carries out the specified subcommands (commands) on each marked line. A single command or the first command in a subcommand list appears on the same line as global. The remaining commands must appear on separate lines, where each line (except the last) ends with a (backslash). The default subcommand is print. The subcommand list can include the append, insert, and change subcommands and their associated input. In this case, if the ending period comes on the last line of the command list, you can omit it. The undo subcommand and the global subcommand itself, however, cannot appear in the command list. See also Substituting Text. Moving or Copying Text Repositions the specified line or lines to follow address3. The first of the moved lines becomes the current line. address1 and address2 are optional; you must specify address3. Places the specified line or lines in buffer (identified by a single alpha character name a to z). Retrieves the contents of the specified buffer and places it after address. If you do not specify a buffer, edit restores the last deleted or yanked text. Thus, you can use this subcommand together with delete to move lines or with yank to duplicate lines between files. Quitting an Editing Session Ends the editing session. The quit command does not write the editor buffer to a file; if you have modified the contents of the buffer since the last write, edit displays a warning message and does not end the session. In this case, either use the quit! subcommand to dis- card the buffer or write the buffer and then quit. Saving Text Writes the contents of the specified line or lines to file. The default range is all lines in the buffer. edit displays the number of lines and characters that it writes. If you do not specify a file, edit uses the current filename. If file does not exist, edit creates it. Saves the current editor buffer as though the system had just crashed. Use this command when a write subcommand has resulted in an error, and you do not know how to save your work. Recovers file from the system save area. Use this after a system crash, or a preserve subcommand. Substituting Text Replaces on each specified line the first instance of pattern with the replacement pattern replacement. If you add the global indicator g, it replaces all instances of pattern on each specified line. Undoing a Change Reverses the changes made in the buffer by the last buffer editing subcommand. Note that global subcommands are considered a single sub- command to an undo. You cannot undo a write or an edit subcommand. SEE ALSO
Commands: ed(1), ex(1), vi(1) edit(1)