Linux - NewbieThis 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!
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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Having a problem trying to make a command that will copy part of a file to another part of a file. smb.conf file is the file that is being edited. Appending an already creating valid users list, to another share with the same valid users. The reason for this is so whenever new users are added with another script, they are appended to Share1, this will be updating the new share with newly created users on Share1. Will i need to use awk or sed?
valid users = user1, user2, user3, user4, user5, user6, user 7
valid users = (add all Share1 valid users here)
If you want to append to a file, use redirection >>.
If you want to write to different files with a single command, use tee(1).
If you want to append something at the end of a specific line in a file, use sed(1), see, e.g., http://www.linuxquestions.org/questi...e-done-684650/
Basically what I want is to have Share1's Valid Users be appended to Share2's when the share is created. Currently, I have a script that will attach new users to Share1. When I make a new share, with another script, I want the all the users for Share1, to be added to Share2.
p.s. Share2 isn't created yet, but when it is, I'd like to have all Share1's users be added to it.
couldn't you simply copy Share1 to Share2 right after creating share2? If there is a chance there is already a member in share2 I would use the append such as:
cat share1 >> share2
This will add share1 to the end of share2
DotHQ, let me explain the situation a bit further..
The problem is that there won't be a user to maintain the system / smb.conf file, so I'm writing scripts that will make new shares and add existing users. There will be someone who can log into terminal and run scripts, but nothing more than that.
I have a script that adds users to samba, and then add them to a root share (directory), which then has many other files inside of it, which are all shares themselves for speecific users and have specific permissions for each.
Since there will be new users being added, i'd like to copy the valid users from Share1 (since it will have every user there is on the system), to the new Share2. A simple (not for me lol), cp from Share1's Valid users to be mimiced to Share2's Valid users.
If you mean the output file was empty:
Which version of sed are you using?
Could you post your smb.conf file in code tags to preserve spacing?
I've just tried the sed code on my own smb.conf file and it works as expected.
If you mean the input file was deleted:
Perhaps you used the same file for both input and output.
'infile' and 'outfile' should be different or the contents of the file will be deleted due to redirection '>'.
sed doesn't delete the input file unless the '-i' option is used.
Well, your right, I did do /etc/samba/smb.conf > /etc/samba/smb.conf, assuming it would edit itself. I figured a solution out though, which won't require me to even make a share, but to just give new folders that are added 777 permissions so all users can wrx them.. less clutter this way I suppose.