LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-26-2017, 06:03 AM   #1
Ankit yadav
LQ Newbie
 
Registered: Jun 2017
Posts: 22

Rep: Reputation: Disabled
single command for creating file and setting permission to it.


Hi All,

I want to know is there is any command which let me create file and set to some permission(other than default).

Like we can do with directories with command
mkdir -m 777 testdir

Some where I found "install" command. But again i successfully able to create directory from it, not file.

Is there is any way to do it. Or we should follow touch file;chmod 777 file command itself.

Thanks in Advance.
 
Old 06-26-2017, 06:44 AM   #2
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
No 'single command'. EDIT: corrected to Yes, in post#5 below; see man install
Have a study of: man creat
There's always umask: https://unix.stackexchange.com/quest...-touch-command
Oh, maybe visit my favorite command: strace Enjoy your Linux!

Last edited by Jjanel; 06-26-2017 at 09:09 AM.
 
Old 06-26-2017, 06:50 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
It depends on how you define "single command". You can string several commands into one "script", and run the script as a single command. But caveats, as when you lose the script you might not remember the commands. And if you're on someone else's system, they wont have your script.
 
Old 06-26-2017, 07:04 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
correct it is more done in steps, first create, then change permissions two commands one line

Code:
$⚡ ~ ⚡> touch changePermissionsOnMe ; chmod 777 changePermissionsOnMe
 
Old 06-26-2017, 07:59 AM   #5
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Cool A *single* command!

Oh: ooops: I found this (/dev/null 'trick' to make install 'work'):
https://unix.stackexchange.com/quest...e-command-line

Code:
install -m 7666 /dev/null MYrwSrwSrwT
ls -l !$ ; echo hi > !$ ; ls -l !$ #echo stole my Suid;Idk WHY?
is devilishly BWeatiful Thanks OP, for getting me to learn install

p.s. Got milkstdin?: echo hi | install -m 7666 /dev/stdin MYrwSrwSrwT

Last edited by Jjanel; 06-26-2017 at 09:03 AM.
 
1 members found this post helpful.
Old 06-27-2017, 02:09 AM   #6
Ankit yadav
LQ Newbie
 
Registered: Jun 2017
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks Jjanel

Its worked $install -m 755 /dev/null newfile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating VM from kickstart file, hangs in single user mode mzkaren Linux - Newbie 4 05-14-2013 10:22 AM
[SOLVED] Permission Denied When Creating File hitmen Linux - Newbie 6 07-12-2011 12:44 AM
[SOLVED] What should the permission setting for the /etc/shadow file be? chris1973 Linux - Newbie 3 08-15-2010 02:21 AM
Creating user with password in single command karipineni_18 Linux - General 3 01-16-2010 05:16 AM
Setting permission, file access. Apogeal1 Linux - Newbie 5 06-20-2005 08:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration