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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-26-2017, 06:03 AM
|
#1
|
LQ Newbie
Registered: Jun 2017
Posts: 22
Rep: 
|
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. 
|
|
|
06-26-2017, 06:44 AM
|
#2
|
Member
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
|
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.
|
|
|
06-26-2017, 06:50 AM
|
#3
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
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.
|
|
|
06-26-2017, 07:04 AM
|
#4
|
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
|
correct it is more done in steps, first create, then change permissions two commands one line
Code:
$⚡ ~ ⚡> touch changePermissionsOnMe ; chmod 777 changePermissionsOnMe
|
|
|
06-26-2017, 07:59 AM
|
#5
|
Member
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
|
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 MYrwSrwSrw T
Last edited by Jjanel; 06-26-2017 at 09:03 AM.
|
|
1 members found this post helpful.
|
06-27-2017, 02:09 AM
|
#6
|
LQ Newbie
Registered: Jun 2017
Posts: 22
Original Poster
Rep: 
|
Thanks Jjanel
Its worked $install -m 755 /dev/null newfile
|
|
|
All times are GMT -5. The time now is 08:58 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|