A shell is terminology for a command-line interpreter most commonly used with Unix-like operating systems, but also used to interact with GUI-based operating systems in a more granular fashion. Not only does it allows the user to run programs from a text interface, but frequently offers basic ...

learn more… | top users | synonyms

18
votes
23answers
30k views

Finding the Public IP address in a shell script

I can find my IP address using ifconfig or hostname -i command. But how do I find my Public IP? (I have a static public IP but I want to find it out using unix command)
14
votes
1answer
10k views

How to interpret output from Linux 'top' command?

Following a discussion made HERE about how PHP-FPM consuming memory, I just found a problem in reading the memory in top command. Here is a screenshot of my top just after restarting PHP-FPM. ...
25
votes
5answers
2k views

Linux server out of space

I have been asked this question in two consecutive interviews, but after some research and checking with various systems administrators I haven't received a good answer. I am wondering if somebody can ...
10
votes
7answers
11k views

How to log every linux command to a logserver

I want every single command typed to go to a logserver. Already configured is the syslog-ng to send all logs to the logserver. I'm interested in any and all methods to do this. I would expect ...
4
votes
9answers
10k views

How to restrict the users' shell allowing to execute shell programs

Is it possible to prevent any user to not use commands like ls, rm and other system commands which could harm the system. But the users should be able to execute shell programs.
15
votes
9answers
11k views

Live view of Linux shell commands executed by another user?

Is it possible for the root user in Linux to have a real-time (or close to real-time) view of the shell commands being run by another user logged in via a terminal or SSH? Obviously they're stored in ...
6
votes
2answers
2k views

My cron tasks report command not found [duplicate]

This is the contents of my crontab file: 0 0,6,12,18 * * * cd /var/www/app/current && backup perform --trigger db_backup --config_file config/backup.rb --data-path db --log-path log ...
5
votes
1answer
439 views

“runas” or “sudo” equivalent on AS400 IBM iSeries

I'm trying to invoke a program to run as another user (by getting input user/pwd) in AS400 OS using Java. Like runas in Windows or sudo in Unix — what can we do in AS400 OS? I am able to invoke basic ...
3
votes
3answers
3k views

How can I display the IP address of an interface?

If I want to display the IP address that is assigned to eth1, how can I do this in Bash?
102
votes
3answers
35k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
8
votes
7answers
4k views

BASH shell session logging on remote host

What's the best method of logging a BASH shell session to a file on the host machine? The preferred output format would be equivalent to PuTTY's "printable output" log setting, as viewed by the user ...
4
votes
2answers
4k views

mysqldump prompting for password in shellscript

I wrote a simple shell script to dump a specific mysql database. problem is it is prompting me for a password even though I provide on. The mysql db is version 5.0.27 if that matters. Here is the ...
13
votes
9answers
1k views

Is there a paging version of `watch`?

Under a UNIX shell, how can I get a similar effect to the watch command, but with paging so that I can scroll around in the output if it takes up more than one screen? In other words, I want a ...
12
votes
6answers
36k views

Run a shell script as a different user

What's a good way of running a shell script as a different user. I'm using Debian etch, and I know which user I want to impersonate. If I was doing it manually, I would do: su postgres ...
4
votes
4answers
874 views

Accidentally ran chmod 775 -R / (not ./) on linux server (RedHat)

I accidentally ran "chmod 775 -R /" instead of "chmod 775 -R ./" and changed the permissions for everything and now the server is broke. Anyone know how I can quickly fix this???
4
votes
4answers
831 views

Linux: How to change the extension of a bunch of files?

I have a directory full of files ending with .xxx. (Apple.xxx, Orange.xxx, Bannana.xxx) I want to change their extensions to .yyy. (Apple.yyy, Orange.yyy, Bannana.yyy) What's the quickest way to ...
3
votes
4answers
8k views

Linux / mysql: is it safe to copy mysql db files with cp command from one db to another?

Most guides recommend mysqldump and simple SQL for copying one table to anoter db. How about linux shell cp? Can I just simply do cp /db1/mytable.frm /db2/mytable.frm
1
vote
2answers
850 views

executing a sh script from the cron

I have a test.sh script #!/bin/sh php /home/v/file.php sh /root/x/some.sh when I execute the file as root from command line it works. sh /home/v/test.sh when I set it to crontab -e (is the root ...
7
votes
4answers
4k views

How do I setup SFTP for sites without giving shell access?

I'd like to use SFTP for all the sites on my cPanel CentOS server as we had an FTP password hacked before (not hard). However I don't want each sites SFTP account to have shell access (not even jailed ...
4
votes
5answers
3k views

Script to delete files older than 30days

Shell script should not delete any files under* root dir*. My* path will be like /export/home/ftp/ ... I did some research and figured out the way for finding and deleting the files older than 30 ...
3
votes
1answer
17k views

How to conform to update-rc.d with LSB standard?

This is a migrated question from stackoverflow, as I was told, this is the place for it to be. http://stackoverflow.com/questions/2263567/how-to-conform-to-update-rc-d-with-lsb-standard I have set ...
1
vote
2answers
154 views

How can you see the processes which you put to background?

This question is based on this thread. How can you see the processes which you put to background?
0
votes
1answer
938 views

Allow www-data to execute shell script

I have a shell script called boot.sh on an Ngnix server I am trying to call it via PHP, but I don't think I have permissions. How can I give www-data permission to run boot.sh - and only boot.sh ...
0
votes
3answers
1k views

Migrating users and mailboxes from postfix / Maildir to Postfix with Mysql backend

So I've got 60 or so users on a hand rolled postfix installation on openbsd and I'd like to move their mailboxes to our new mail server running iRedMail (postfix, vmail/mysql back end) Does anyone ...
0
votes
5answers
425 views

cat, pipe, and acroread - why is it failing occasionally?

in a simple shell script I'm trying to run this command: cat /filelocation/myoutput.PDF | /opt/Adobe/Acrobat7.0/bin/acroread -toPostScript Under most circumstances this is working. Occasionally ...
-2
votes
1answer
216 views

shell script doesn't run correctly in cron [closed]

I want to call a shell script I wrote from a cron. The shell script uses the program Linkchecker. If I run the shell script from the terminal it works just fine. However, when cron runs I get the ...
34
votes
1answer
7k views

What is the difference between a 'Login' and an 'Interactive' bash shell

What is the difference between a ‘Login’ and an ‘Interactive’ bash shell? I have quoted Wikipedia below but can anybody give a better answer? EDIT: This is a community wiki so maybe rather than ...
16
votes
5answers
25k views

How to hide the output of a shell application in Linux?

How to hide the screen output (printf) of a shell application in Linux?
9
votes
4answers
7k views

Need to fix file permissions in a user's home directory

Does anyone have a tool or script that will recursively correct the file permissions on a directory? On an Ubuntu Linux machine, a bunch of files were copied to a USB disk with full 777 permissions ...
22
votes
3answers
10k views

What is the difference between unlink and rm?

Is unlink any faster than rm?
22
votes
6answers
45k views

How can I kill all stopped jobs?

When I try to exit from my Linux server I get the message: There are stopped jobs. : Is there a single command to kill these?
11
votes
4answers
9k views

run script as user who has nologin shell

All I need to do is to run a specific script as a particual user who does have the nologin/false shell indicated in /etc/passwd. I would run the script as root and this should run as another user. ...
10
votes
6answers
3k views

What distributed shell utilities do people feel are good, flexible, and easy to use? [closed]

I've been searching and collecting links for a lot of them, but many of these tools don't have enough use case or demonstration documentation to be able to evaluate their potential worth without ...
8
votes
2answers
3k views

Run command as Linux “system” user (shell = /bin/false)

I created a "system" user in Ubuntu 11.04 (adduser --system) for running certain cron jobs, but sometimes I want to test things out by manually running commands as that user. What's the easiest way to ...
5
votes
6answers
10k views

Command to prepend string to each line?

Looking for something like this? Any ideas? cmd | prepend "[ERRORS] " [ERROR] line1 text [ERROR] line2 text [ERROR] line3 text ... etc
5
votes
4answers
1k views

What is the purpose of “source” (.) as a shell command?

What is the difference between these two commands? . filename # (A) and filename # (B) And how is this command related? ./filename # (C) Note: The # and the ...
6
votes
2answers
3k views

find command default sorting order

what is the default sorting order for entries returned by the linux find command? For example, if I issue find . -type f -name '*mp3' and the output consists of multiple files across multiple ...
5
votes
2answers
2k views

Is there a way to configure bash to always page output?

I'd like to configure bash to page the output of all commands. Essentially, I want bash to behave as if every command I enter ended with '| less'. Is this possible?
5
votes
2answers
813 views

What is the purpose of each of the different UNIX/Linux shell startup files?

Previously, when setting up a *NIX environment for the first time, I would put all of my shell customisations into .bashrc, with the following .bash_profile: if [ -f $HOME/.bashrc ]; then . ...
2
votes
6answers
11k views

How to rename multiple files by replacing word in file name?

Replace ACDC to AC-DC For example we have these files ACDC - Rock N' Roll Ain't Noise Pollution.xxx ACDC - Rocker.xxx ACDC - Shoot To Thrill.xxx I want them to become: AC-DC - ...
11
votes
2answers
8k views

When to use single-quote, double-quote in grep?

While trying to search for a simple pattern "hello" in a file, all the following forms of grep work: grep hello file1 grep 'hello' file1 grep "hello" file1 Is there a specific case where one of ...
4
votes
5answers
915 views

Bash: Quotes getting stripped when a command is passed as argument to a function

I am trying to implement a dry run kind of mechanism for my script and facing the issue of quotes getting stripped off when a command is passed as an argument to a function and resulting in unexpected ...
10
votes
3answers
7k views

Force SSH to use a specific shell

Is there any way to force SSH to use a particular shell on the remote end, regardless of what the user's default shell is? I've tried solutions akin to: ssh host.domain.com /bin/bash -c ...
7
votes
6answers
5k views

Find out how many DNS Queries/month via WHM or SSH?

Is it possible? We have complete control over our DNS server and the server actually being pointed to. We are interested in how many DNS Queries we are currently getting, as we want to move to Ultra ...
6
votes
6answers
4k views

Monitor the shell activity of a user on your Unix system?

Trust, but verify. Let's say I want to hire someone a sysadmin, and give them root access to my Unix system. I want to disable X windows for them, only allow shell usage (through SSH, maybe), so that ...
5
votes
3answers
2k views

How to edit command completion for ssh on zsh?

I'd like to set up command completion on zsh to display host names after I type ssh [TAB] taking the names out of my .ssh/config file (and preferably from known_hosts and /etc/hosts and anywhere ...
4
votes
2answers
3k views

Unix separate multiple commands which has '&' (execute in background) in the end

To separate regular commands in Unix is to put semicolon in the end like this: cd /path/to/file;./someExecutable; But it seems not working for commands like this: ./myProgram1 > /dev/null & ...
3
votes
3answers
823 views

Log commands executed over ssh

I would like to log all commands executed over SSH. Say, ssh something@server.com COMMAND I want to log "COMMAND" on server.com I did search extensively but could not find anything. There is ...
2
votes
9answers
5k views

How can i find out the server specs in unix?

Tried to search but can't find anything. Is there an unix equivalent to right clicking / properties on My Computer to see things like memory, cpu speed etc ?
2
votes
5answers
1k views

Shell command to remove files extension

I have a directory with automatically generated files that all end with the .sample extension. I would like to have a way to remove the .sample extension from them all in one terminal command. I ...