I have come across this question many times and recently had this discussion again: "I wrote a script to cd into a directory for me. How come it doesn't work when I run it?" I have seen some information out there on google but there doesn't seem to be one centralized answer, so I will try to offer one here. For those of us that have taken an operating systems course, you should understand why already (or I am assuming you know, as processes are such a fundamental part of an operating system). For everyone else, here is my simple/unofficial explanation, how to accomplish what you are after. This assumes you are running a bash shell (run the command "echo $SHELL" if you aren't sure). I can't be certain that all of the solutions below will work in all shells.
The shell, terminal, console, whatever you want to call it is a running process in the operating system. It has what is known as an "environment". You can see all of the variables in this environment by running the "set" command without any arguments. When you invoke a script, you are actually spawning a child process, that has a totally different environment. Any modifications made to the environment for the child process cannot be made to the parent environment. For example:
I'm using OpenSSH 5.5p1 on Fedora 15. I'm trying to get a chrootDirectory to work. Specifically trying to figure out why I can't write files to a sub-directory of the chroot directory. I created a user test_user and created a group called sftp. I added test_user to the sftp group. I edited /etc/ssh/sshd_config as follows:
Code:
Subsystem sftp internal-sftp Match group sftp ChrootDirectory /home/sftp_users/%u X11Forwarding no
I tried to read the File Permissions page on the wiki and my eyes glazed over after about three sentences. I've got a folder called /var/www/pics that I just want to be able to save image files to. My only other choice as I understand it is to save them to my home folder, then use a "sudo mv" command to copy files to that directory. How do I give my account permissions to save a file in that directory?
How do I use "chmod" command so that it allows me to write a file inside a certain directory ? This directory has permissions in the formdrwxr-xr-xOnce I try to write a file there, it says "Permission denied" ! Don't advise to use "sudo", since the file is created by some executable program compiled from a source code. If I was creating the file myself, I wouldn't have gone to this forum.
I'm pretty new to Linux but I know my way around. I've gotten Google Earth downloaded and am trying to install it. Everything is fine until I try to install it into /usr/local (or somewhere in there). The Google Earth Setup keeps telling me that I do not have write permissions on this directory. Question: How do I change the write permissions for this folder? Or should I install the program somewhere else? The last program I installed (xMind) installed into /usr/local.I am the only user (administrator
kernal 2.6.38-8 After updating Kubuntu-the log in screen will not progess to the desktop. It freezes and then shows the message "no write access to the home directory.." Goggling the problem - references to an .ICEauthority in my home directory are mentioned as linked to this problem. However "ls -la /home/charles" reveals that there is no .ICEauthority file present.
On my laptop for testing, I simply chown each subdir of /var/www to my myuser:www-data. But, now that I am setting up a public facing server, I'm wondering if this is the proper way to do so? If not, what is the best way to allow a non-root account to write to /var/www.
This might see a dump question but I will make it anyway .Here is the scenario:I have two users on my Linux Mint installation:
User A User B
I want User A to be able to write on User B home directory, say /home/B.For this I have changed users's B home directory to look like this:ls -ld drwxrwxr-x 36 B music 4096 2010-09-26 10:31 /home/BI have created a "music" group and assigned to /home/B, so all users that are member of "music" are going to be able to write on User B home directory, right?The answer is No! Not here in my box Can you tell me why?Why users under group music can't write on /home/B if B directory is owned by group music and group music has write permissions?
How can I write a script that will go through the files in a directory and print on the screen the name of the files stating if it is a file or directory. The directory is already provided by the user.
I have created directories in root. I am looking for the chmod command to allow all users read and write permissions to a specific directory. I have done chmod 775 for a file but I need this for a directory. This includes permissions on all files and sub directories.
I'm trying to write a script that will calculate a directory size and if the size is greater than 4GB, it will send out an email. But I am getting the "integer operation expected" error when it tries to calculate the current disk size. Here's my script.
Code:
TO="user@email.com" SUBJ="Ready for DVD burning on `hostname`" MAIL="/bin/mail"
I have a bunch of files that contain a date, then data. When I use join, I get exactly the output I need. But manually joining the first with the second, then that output with the third and so on would take days. I have thousands of files. Can any of you folks help me write a script that would do this?To put it another way, for clarity's sake, here is what I am currently doing
If I were to repeat that 3000 times the final output would be what I need. I know a simple script would do this for me, but I can't figure out how to write it.
In my tmp directory some logs are creating continue (with name logs.txt1, logs.txt2 up to 245). Some times these logs are creating continue within 1 or 3 second gap, now I want to write a bash script that continue monitor the tmp directory and if any time logs create simultaneously within 1 or 3 section gap it will alert me..( generally logs are create with the gap of 5 or 10 minutes duration or some time after one hours )
I need to give a user write access to /var/www and its subdirectories. The current directory permissions are as follows:rwx r-x r-x root root
I added the user to the root group but that didn't seem to help.I read I could chmod -R to change the access to write for the www directory and subdirectories but I don't want to change things and mess up the website. How can I give the user access to write to the www directory and subdirectories without messing anything up? Would changing the www directory group owner to his group cause an issue anywhere?
I'm trying to write a bash script that gets the list of files in a directory and puts them into a variable, then checks each entry and outputs them as follows:
item1 is a FILE item2 is a DIR item3 is a DIR etc etc.
I am able to get the list of files into a variable, but unsure how to get the output I want.
When I log on a root and attempt to issue the command Freshclam to upgrade the virus definitions it attempts or create a new file with a definition name. I get a message stating that the directory isnt writable. The user and group access rights are as follows:
USER = read, write, execute Group = read, write, execute All= read, execute.
The only way I can get around this is by applying a 777 which would be read, write and execute for all. Now, I have a group define with several user ids in it including Root.How do I connect the group with the directory/file so I dont have to apply a 777 access right to group users could issue the Freshclam command.
I am new to writing shell scripts. So, please bare with me. I am currently trying to write a shell script which will read the directory path as input from user and will traverse the Dir tree to find all available audio and video files. I have tried to write as much as I could but I don't know where I am making mistake as I get some files to be audio file which are actully tar balls. On the second note there are some files which video but script shows them to be audio. And, some video files are completely skipped. I am giving the shell script below so that you can see. I am using two external files as source which I am attaching.
Code:
#!/bin/bash #Let's load the extensions that we want to search for vdExt=$(cat vdExtList) adExt=$(cat adExtList)
I need to write a script to report useful information on disk utilization for each user's home directory.For each directory I need to show: 1. the long listing of that directory entry (but not the files in the directory), so that I can see the rights and owners of the directory.2. The amount of disk used by that directory, in human-readable format, including subdirectories. I need to have two lines for each user one after the other. For example:
/home/user1 directory info /home/user1 disk usage /home/user2 directory info /home/user2 disk usage
The script will assume that all users, except user root, have their home directories in the /home directory (no need to do anything with the /etc/passwd file). And if the administrator adds or removes users, the script should still work correctly (so the script shows the information for all current users).
Here's what I do know. The command "ls -ld /home/user's_name" will give me the info I need for #1. And the command "du -hs" will give me the info I need for #2. What I don't know is how to grab each individual directory in order to apply the above commands to each of them in order. ???
Its been a while (maybe too long) since I last used yum to check for updates / install anything on my server, but when I tried the other day I got the following response:
# yum list updates Loading "installonlyn" plugin Setting up repositories Error: Cannot find a valid baseurl for repo: updates[code]......
Trying other mirror.Error: Cannot open/read repomd.xml file for repository: updates
A few weeks ago there were some network changes, but nothing else should have changed OS side.I have checked /etc/resolv.conf and that looks ok - ping and wget have no problem resolving hostnames.I tried setting enabled=0 in yhe .repos files - this allowed me to do a 'yum list', but 'yum list updates' returned an empty list - I am definitely not 100% up to date!
P.S. Attachment not there at the moment - getting the following error when I try to upload the zip file...Errors Returned While Uploading
Failed to open directory with write permission: /var/wwwthtml/oldwebcopy.centos.org/uploads/newbb
I want to write a shell script which will simultaneously collect OS user information and write in an individual text files.Can anyone tell me the syntax of the script.N.B. The user name will be mentioned in an array within the shell script.
df -h [URL] I did the following command to find everything is in /usr or /var, then tracked it down to /usr/lib and /usr/share as the main offenders, but out of all the directories none are more than 1mb or so.
du -sh /* | sort -gr | head -n 5
I tried to uninstall firefox, which is what got me in this mess in the first place, the log claims it will remove ~240 mb but failes on a "E: Write error - write (28 No space left on device)" [URL] If I could juggle something onto an external hard drive so I can uninstall firefox I would be out of the wood. Failing that I believe a new install is in order.
I've done a low level format on them so they're completely empty. When I use them with my windows machines, they're absolutely fine. When I plug them into my Ubuntu machine, there is a hidden directory created called 'RECYCLER' which I'm assuming is for deleted files?However, it also creates a .exe file in this directory called 0x2D9FA278 which has an Icon with an H in it and a comment of 'Facebook Photo' This has the effect of making all the directories on the stick into shortcuts! I googled the file name and it seems to be some sort of Trojan, but I don't understand how it's go into my Ubuntu machine, I've scanned with ClamAV and it finds nothing.