ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
1) it is working now. I am learning shell script, appreciate your reply.
2) Appreciate if you can help.
The objective : The users can only see his department folder when he login.
In my linux server, I have created 2 departments (acct and mkt department). In acct department, I have (useradd) acctuser1 and acctuser2. In mkt department, I have (useradd) mktuser1 and mktuser2.
In my (/home/AusDepts) is a directory contain all the department folders.(/home/AusDepts/acct) and (/home/AusDepts/mkt).
When acctuser1 login, a soft link (ln -s source target) will be created in his /home/acctuser1 directory link to /home/AusDepts/acct). That's mean when acct user login he can see his accounting department folder. Whereas mktuser login he can see his marketing department folder.
How can I do this ? In my /home/acctuser1/.bash_profile I have added :
ln -s /home/AusDepts/acct acct
But it doesn't link once. First is say the target directory doesn't exit. when I created the target manually, It provide endless link ?
Appreciate if you can advise or provide alternation suggestion to the solution.
Set it up statically, that is make the link only once. Note that only the root can symlink directories, because of security implications.
Perhaps I dont understand what you try to do. Since every user has its own home directory, it should be easy to create a link in his/her home dir to the department dir. If there are (will be) many users, consider creating a script to create. This script should create the /etc/passwd entries (calling adduser or useradd) and create and fill the home directory.
.bash_profile is an ordinary shell script. You can call login.sh like any other executable. Example (provided login.sh is placed in a directory that is in $PATH)
# call bash builtin (there is also a standalone executable, do help set)
echo "The path is $PATH"
# call the cat program
# same, with explicit path
# now for login.sh
Take care of these points:
- The directory in which login.sh is placed should be in the path
- It should be executable by whoevere runs .bash_profile (the owner of the home directory in this case). Do a ls -l, and possibly a chmod.
- Beware of other programs called login.sh, whose directories are also in $PATH. Use the which command to check.
Sorry x2000koh, but i know very little about shell scripting. I just knew the answer to your original question because i encountered it before (it happened because the current directory you worked in wasn't part of the search path, by adding ./ you specify where the file is - you can also directly add your current dir to the path too instead).