introduction computer programming

timer Asked: Jan 19th, 2015

Question description

Write your own version of the chmod command.

Your solution should be able to set each of the bits for the group, owner, and world groups
The first argument will be the mode to change the file to and the second argument is the file name.

Usage:  chmod MODE FILE

Invoking the command with improper usage should display an appropriate help message.

Sample run:

Given a file named foo.txt:

sets the permissions to rwx for each group:
./chmod 777 foo.txt 

sets the permissions to rwx for owner, and --- for group and world:  ( -rwx------ )
./chmod 700 foo.txt 


Remember, to make an octal literal, precede your integer literal with 0.
Thus, 0777 would be 777 in octal.
You can store ocatls in long integers.

long int mode = 0777;

Stores octal 777 in variable mode.

The chmod function accepts an octal argument.

Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors