date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,667,594,652,000
A domain name is an abstraction for an IP address. Regardless of which computer is at that IP, the domain name should point there. So why then do we associate a domain name with a computer using the /etc/{hosts,hostname} and/or systemd's hostnamectl? I'm definitely clueless, but this just seems wrong to me. I'm set...
In /etc/hostname (see man 5 hostname) you can and should set the local hostname of your server. This name may be used from software running on this server. This is just a string, which is not visible outside of the server. In contrast, the file /etc/hosts is used to resolve computer names to IP addresses. You can thin...
Domain Name as IP Abstraction vs. Domain Name as Name of Server - /etc/host{s,name} - Why?
1,667,594,652,000
I use the following syntax in order to find the domain name on a Linux machine: hostname | sed s'/\./ /g' | awk '{print $2}' hostname master02.sys65.com hostname | sed s'/\./ /g' | awk '{print $2}' sys65 but I think this approach is not very elegant. I would like to see other ways to find the domain name (without t...
You should use hostname -d for this. To drop the last part of the domain, there any many different techniques; for example hostname -d | sed -E 's/\.[^.]+$//'
What is the best approach to find a system's domain name?
1,667,594,652,000
On my work's network, my new debian headless VM is not visible via its hostname. I'm using: Debian Jessie Virtualbox bridged adapter I can see other VMs on my machine from the headless VM, and I can see other machines on the network from the headless VM (that is, ping machine works for both cases). I can also ping th...
Your Windows machines can use NetBIOS Name Resolution to tell each other about themselves. This is Microsoft specific protocol and doesn't work with Linux/Unix machines, which use a static file (/etc/hosts) or the Domain Name Service (DNS) for name resolution. Your Windows machines will not recognise the AVAHI servic...
Can ping Debian VM via IP but not via hostname
1,667,594,652,000
Unfortunatelly I made mistake somewhere but can't get where. I had issues with ssh and github, tried different things and they didn't work. Later I decided .. i think.. moved file i balieve it was home/username/known.hosts or smth like that. Additonally I deleted everything from folder, where id_25519 and id_25519.pub...
It's unlikely modifying anything in your home directory will have reset your password. On most distributions it's stored in /etc/shadow by default. To get to a recovery console, the most easy thing to try is to change the init kernel parameter on boot. Assuming you are booting with grub: switch on your computer At th...
password to linux changed after deleting/manipulation with ssh
1,667,594,652,000
I just installed EndeavourOS. I set my hostname using the command sudo hostnamectl set-hostname shuttle. When I try to ping shuttle from my other machines it is not able to resolve the IP address. I have another machine with Kubuntu installed, and I am able to ping the Kubuntu box. So it means my router isn't the prob...
The mere fact of setting the hostname of your system alone is not enough to make it known to other systems in your network. Even if your router actually has a DNS service that can be aware of hosts on your local network (and this is not certain by any means), your DHCP client must 1.) actually pass the locally-configu...
Can't ping or DNS resolve the EndeavourOS machine
1,667,594,652,000
I've been looking to a tutorial on how to customize my terminal. When I try to customize the PS1 into something like PS1="\u@\h \W -> " export PS1; After I source the file in the terminal, instead of getting the username@host directory I get \u@\h \W -> What I have so far in my .bash_profile and .bashrc files is:...
What output do you get for echo $0 ? The output is -zsh Which seems to mean you're running Zsh, not Bash. Zsh doesn't support Bash's prompt expansions, but has a system of its own. See: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html Try to put something like this in .zshrc: PS1='%n@%M %~ -> ' You coul...
Special characters don't work in bashrc
1,667,594,652,000
I'm used to debian/raspbian, setting the hostname for a computer is easy as: /etc/hostname: my-computer and /etc/hosts: 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters 127.0.1.1 my-computer After these changes and a restart, I can ssh [email...
For ssh [email protected] to work, two things must be in place: my-computer must be running avahi-daemon or some other implementation of multicast DNS (mDNS for short). This will periodically announce the current hostname & IP of the computer to the local network, and will respond with that information if some other ...
Gentoo: how to set hostname for local network?
1,667,594,652,000
I have a Linux server # uname -a Linux site 3.12.39-47-default #1 SMP Thu Mar 26 13:21:16 UTC 2015 (a901594) x86_64 x86_64 x86_64 GNU/Linux # lsb_release -a LSB Version: n/a Distributor ID: SUSE LINUX Description: SUSE Linux Enterprise Server 12 Release: 12 Codename: 12 I had to change network set...
Your DHCP client can be configured to override the hostname given to the machine by the DHCP server. Depending on what DHCP client you use, this may be done differently. dhclient may be configured with supersede host-name "site"; in /etc/dhclient.conf, for example. Unless you have very special requirements, I'd sugg...
My Linux server forgets its host name every day
1,667,594,652,000
I would like the hostname command to show the fqdn by default on CentOS Linux. What must be done to get this behavior? I am not looking to alias hostname to 'hostname --fqdn' I am looking to modify the system in a way that the gethostbyname calls, or whatever is used to get hostname get the entire fqdn ala host.exa...
Add the FQDN hostname to /etc/sysconfig/network: HOSTNAME=host.example.bar After a system restart the hostname command (without any options) should display the FQDN. [user@host ~]# hostname host.example.bar This works on CentOS 5/6.
Get hostname to show fqdn without --fqdn
1,667,594,652,000
We have tried both the /etc/hosts and also /etc/sysconfig/network. Edited both files and service network restart. Yet the hostname is showing as localhost.localdomain. How to resolve on this? Googling almost all talking about the same method too.
From this answer : How to change the hostname of a RHEL-based distro? Have you tried running the command : hostname new_hostname where "new_hostname" would be value you are trying to set ?
Editing /etc/hosts and /etc/sysconfig/network doesn't chane the hostname [duplicate]
1,667,594,652,000
I want to set name to my localhost.for example I want mysite.com instead of localhost/mysite how to do that? I have searched but couldn't get a solution for Linux.
Find and change the following line in /etc/hosts: 127.0.0.1 localhost Change it to 127.0.0.1 localhost mysite.com This is client side. Your webserver may need be configured for name based vhosts.
How to set name to localhost in fedora15?
1,667,594,652,000
When trying to ssh from terminal into my raspberry pi using: ssh [email protected] the connection just hangs forever. When I ping [email protected], I get ping: cannot resolve [email protected]: Unknown host I can ping and ssh with the ip address just fine using: ssh [email protected] Not sure if I need to configure m...
When you give a host a hostname, only this host knows about it. Any other host doesn't know the hostname (and the IP address it corresponds to) at all. A little different are name services (like DNS, NIS, ...), which "distribute" this knowledge across a network. But for our purposes only the host himself knows its hos...
Cannot ssh into a host using hostname.local
1,667,594,652,000
There are two different version of hostname on my system. This is a problem when trying to use wget against $HOSTNAME, which differs from what is expected. [user@box ~]# wget https://$HOSTNAME/login.php --2021-08-22 23:25:07-- https://superserver/login.php Resolving superserver (superserver)... 11.22.33.44 Connecting...
hostnamectl set-hostname superserver.some.domain.com systemctl reboot now
$HOSTNAME mismatch
1,667,594,652,000
I SSH to my Raspberry Pi's wifi via ssh raspberrypi.local, simply done by adding the following code in a file named wpa_supplicant.conf ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={ ssid="Welcome Home" psk="Thanhlich267" priority=1 } I am trying to learn to do the sa...
wpa_supplicant.conf is just for configuring the WiFi network connectivity: it has nothing to do with making the .local hostname available. That part is done by the avahi-daemon service, which is enabled by default on RasPis. It uses the multicast DNS, or mDNS protocol to announce its name and IP to other systems on th...
How to setup a .local Wifi hostname to SSH in a Linux system?
1,667,594,652,000
Assuming a Linux system has both hostname (/etc/hostname) and NetBIOS (/etc/samba/smb.config) enabled. My questions are: Are these 2 names synchronized somehow by default settings? (for example, after installing the samba, does the netbios name = something setting get changed in (/etc/samba/smb.config) to the same va...
'netbios name' is a name used by only some special programs. Your Linux system is in the network represented by all of its IP addresses (try ifconfig | grep inet), where 127.0.0.1 and ::1 are always your local machine. Pinging one of these IP addresses will reach you system. If you have a little more complex system, l...
Accessing a Linux system inside a network: is it via hostname or netbios name?
1,573,097,728,000
I have one box (Rasberry Pi, running rasberian) with a static IP. It's running in a network with a domainname, and I have several DNS-server set up. However, I can not get FQDN name to work on this box: sitron@pi:~ $ domainname (none) sitron@pi:~ $ dnsdomainname sitron@pi:~ $ hostname -f pi I believe I have set up D...
I figured it out, and there is two solutions. I have tested both, on several different boxes. Solution A Verify that your resolv.conf contains the "domain"-keyword, like this: # Generated by resolvconf domain example.org nameserver 127.0.0.1 If you are using dhcpcd.conf to set a static IP like me, you have to specify...
dnsdomainname and hostname -f does not return FQDN
1,573,097,728,000
I'm running Arch on my daily use laptop and I have two SSH terminals open up every time I login. I SSH into another Arch laptop, which is essentially a network connected hard drive in which I backup this laptop via Cron and rsync. The other device is Rasp Pi which is running OSMC and I do basic maintanance with the la...
If you have control over the WiFi you should have control over the DHCP server (in home networks most likely your WiFi router). I would then propose these possible solutions: Configure your DNS server (probably also on the WiFi router) to assign host names to the devices you want to reach. Then you can contact them b...
SSH without knowing IP addresses
1,573,097,728,000
Good day to all. I'll give you an example, I tried it There are 2 entries for BalanceMember in /etc/hosts. Of course, don’t look at these virtual machines, it’s a black box. All requests return to 404 not found. ServerName service.test.com SSLProxyEngine on <Proxy "balancer://service"> BalancerMember h...
<Location "/"> ProxyPass "https://service.ng.com/" ProxyPassReverse "https://service.ng.com/" AllowOverride None Order Deny,Allow Deny from All Allow from All </Location> This block solved my problem. Thank you.
ProxyPass return 404, but one name OK
1,573,097,728,000
I have copied my headless Ubuntu 22LTS server to a backup drive with dd, and I want to deploy it as a backup server with the same relevant settings. What is the proper way to change the hostname on the copied drive before booting it from the backup hardware? As the systems run headless, I cannot login to the console t...
@Tom Yan: Thanks for the link. I have searched for my hostname in config files on my system and found some which are not covered by the 'hostname' command. The main files are /etc/hostname and /etc/hosts, but there may also be /etc/postfix/main.cf and /etc/mailname which require adaptation if postfix is configured. T...
Howto change linux hostname on mounted (copied) drive
1,573,097,728,000
I have a raspberry with a dnsmasq server installed (via NetworkManager). I need to be able to resolve *.raspberry.local on my local (private) network. Here is my config : In /etc/NetworkManager/NetworkManager.conf I've added dns=dnsmasq to [main] In /etc/NetworkManager/dnsmasq.d/local.conf I've added local=/raspberry....
I fixed my problem using this dnsmasq config: domain-needed bogus-priv filterwin2k expand-hosts localise-queries domain=raspberry.lan local=/raspberry.lan/ address=/raspberry.lan/192.168.1.10 expand-hosts no-negcache resolv-file=/tmp/resolv.conf.auto listen-address=127.0.0.1,192.168.1.10 and by changing resolv...
Cannot resolve local sub domain on network
1,573,097,728,000
I want to make it so that instead of a single hostname specified on the command line, it reads in a list of multiple target IP addresses from a file. #!/bin/bash - # bannergrab.sh function isportopen () { (( $# < 2 )) && return 1 # <1> local host port host=$1 port=$2 echo ...
You seem to want to have "$1" represent a file containing a list of targets, instead of being just 1 target. So you will need to englob the main part in a loop ATHOSTFILE="$1" SCRATCH="$2" for ATHOST in $( cat "$ATHOSTFILE" ); do ... # (the rest of the actions here) done Note that the $( cat "$ATHOSTFILE ) part wi...
Instead of a single hostname specified on the command line, it reads in a list of multiple target IP addresses from a file
1,573,097,728,000
This morning the connection and all the things were working fine, until I following some online tutorial, installed Postfix and changed /etc/hostname and /etc/hosts. Now ping to the local router: 198.168.3.1 is working fine, but not when I try to reach anywhere out of the firewall: ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) ...
All thanks to @icarus, just realize that the gateway and router should share the same address which handles all incoming and outgoing traffic. There were 2 routers working for a different purpose earlier, that's why the problem only occurred today because the other router's rule was changed.
Ubuntu Server: After Trying to Set Email Server Using Postfix, Ping 8.8.8.8 Only Gives Destination Host Unreachable
1,573,097,728,000
Let's say I want to run a script when the hostname is change on a machine with hostnamectl set-hostname NAME Is there a way to hook into this? How would I go about doing it?
It is possible. I don't have full instructions. (Feel free to post any script you write etc, and take due credit for it :-). hostnamectl / hostnamed does not run scripts. When you change the hostname using hostnamectl, hostnamed emits a dbus signal called PropertyChanged. You could hook up to the dbus signal, using...
Is it possible to hook into hostnamectl?
1,573,097,728,000
I have created a shell script to connect to a list of servers using sshpass and run a list of about 30 commands. An extract of the script is below. The script will wget a new config file, but then I am stuck trying to replace a variable in the config file with the server hostname. I've had no luck getting the remote ...
You need to escape the $ before the $HOSTNAME variable (or $(hostname) command), so that it is expanded/run on the remote machine rather than the local machine: #!/bin/bash while read PASSWORD SERVER;do sshpass -p "$PASSWORD" ssh -t -p 1234 $SERVER << EOF wget -N https://example.com/file.conf 2>&1 | grep -i "fai...
Output remote hostname in sshpass session
1,573,097,728,000
I set up a basic Wordpress installation (on a Raspberry Pi running Raspbian Stretch - Debian 9) using NGINX. Recently I changed the hostname of my system (as part of a plan to ensure consistent naming across my systems) and everything seemed to be working successfully. I wanted to move my Wordpress installation to a n...
As far as I remember it is not possible to decouple the domain name from the WP instance, but you can change it. In the database you can find where the domain is stored by exporting the database with a mysql_dump and then search within the text file. Another method which entails running MySQL commands is explained on ...
How to make Wordpress independent of hostname
1,573,097,728,000
I host an ubuntu server at a data center and worked well for years till last night the server can not ping itself by host name. No config has been changed. Here are what it can/can not do now. From outside, I can ping the server both by its static IP, and by its hostname. From server, I can ping any website (google, ...
Check /etc/hosts. Probably there's a line with the name of the server and an incorrect IP
From server cannot ping server itself by its hostname while can ping by its IP
1,573,097,728,000
I'm following this guide https://www.linuxtechi.com/configure-domainkeys-with-postfix-on-centos-7/ When I get to this section, it gives an error # opendkim-default-keygen Generating default DKIM keys: Cannot determine host's domain name, so skipping default key generation. I do have my hostname set # hostname domain....
Thanks to RubberStamp's comment, I just viewed the opendkim-default-keygen file and copied & pasted each line manually in another window. # less /usr/sbin/opendkim-default-keygen [root@domain postfix]# prog=opendkim [root@domain postfix]# KEYGEN=/usr/sbin/$prog-genkey [root@domain postfix]# DKIM_SELECTOR=default [roo...
Generating default DKIM keys: Cannot determine host's domain name, so skipping default key generation
1,573,097,728,000
I'm trying to figure out what this (obretschlt2-w7) is, from my command-line prompt. I'm using a conda environment, with the name µ_env, with my Username mu. However I can't figure out where the 2nd field is coming from. I'm logged into a secure server VPN, through my work, but I don't ever recall seeing this. Wha...
Is that not your hostname on your system? Try: cat /etc/hostname Edit: $ echo $PS1 (µ_env) \h:\W \u\$ \h means hostname Source: wiki.ubuntuusers.de/Bash/Prompt Command "hostname" may also show your hostname
What is this random name in my command-line prompt? [duplicate]
1,573,097,728,000
im using this script to change hostname via ssh but i got some errors. read -p "Insira o IP : " ip read -p "Insira o nome do utilizador : " host read -s -p "Insira a palavra passe : " oldpass sshpass -p $oldpass ssh $host@$ip "cat /etc/hostname > hostname.txt"\ run="sshpass -p $oldpass ssh $host@$ip" \ hostn=$($run ...
Instead of replacing name in /etc/hostname file use below command to change hostname if it is a RHEL7/CentOs7 machine hostnamectl set-hostname $newhost
Set hostname via ssh error SCRIPT
1,347,271,313,000
I have 2 graphics cards on my laptop. One is IGP and another discrete. I've written a shell script to to turn off the discrete graphics card. How can I convert it to systemd script to run it at start-up?
There are mainly two approaches to do that: With script If you have to run a script, you don't convert it but rather run the script via a systemd service: Therefore you need two files: the script and the .service file (unit configuration file). Make sure your script is executable and the first line (the shebang) is #!...
How to write startup script for Systemd?
1,347,271,313,000
I just switched to debian jessie, and most things run okay, including my graphical display manager wdm. The thing is, I just don't understand how this works. Obviously my /etc/init.d/wdm script is called, because when I put an early exit in there, wdm is not started. But when I alternatively rename the /etc/rc3.d dir...
chaos' answer is what some documentation says. But it's not what systemd actually does. (It's not what van Smoorenburg rc did, either. The van Smoorenburg rc most definitely did not ignore LSB headers, which insserv used to calculate static orderings, for starters.) The Freedesktop documentation, such as that "Inc...
How does systemd use /etc/init.d scripts?
1,347,271,313,000
I think I read something a while back about this, but I can't remember how it's done. Essentially, I have a service in /etc/init.d which I'd like to start automatically at boot time. I remember it has something to do with symlinking the script into the /etc/rc.d directory, but I can't remember at the present. What i...
If you are on a Red Hat based system, as you mentioned, you can do the following: Create a script and place it in /etc/init.d (e.g., /etc/init.d/myscript).  The script should have the following format: #!/bin/bash # chkconfig: 2345 20 80 # description: Description comes here.... # Source function library. . /etc...
How can I make a script in /etc/init.d start at boot?
1,347,271,313,000
I have set my environment variable using /etc/profile: export VAR=/home/userhome Then if I do echo $VAR it shows /home/userhome But when I put reference to this variable into the /etc/init.d/servicename file, it cannot find this variable. When I run service servicename status using /etc/init.d/servicename file with f...
The problem is service strips all environment variables but TERM, PATH and LANG which is a good thing. If you are executing the script directly nothing removes the environment variables so everything works. You don't want to rely on external environment variables because at startup the environment variable probably is...
How to make unix service see environment variables?
1,347,271,313,000
I am currently trying to understand the difference between init.d and cron @reboot for running a script at startup/booting of the system. The use of @reboot (this method was mentioned in this forum by hs.chandra) is some what simpler, by simply going into crontab -e and creating a @reboot /some_directory/to_your/scrip...
init.d, also known as SysV script, is meant to start and stop services during system initialization and shutdown. (/etc/init.d/ scripts are also run on systemd enabled systems for compatibility). The script is executed during the boot and shutdown (by default). The script should be an init.d script, not just a script...
Running a script during booting/startup; init.d vs cron @reboot
1,347,271,313,000
I'm running Ubuntu where I have the directories /etc/rc0.d, /etc/rc1.d, /etc/rc2.d, ..., /etc/rc6.d. Example files from my machine: directory example symlinks in the dir ------------------------------------------ /etc/rc1.d: K76dovecot, K77ntp /etc/rc2.d: S23ntp, S24dovecot /etc/rc3.d: S23ntp, S24dovecot...
These are runlevels and are a System V-style initiation used by most *NIX systems (with the notable exception of systemd-based systems). When booting the kernel/user decides what runlevel should it run and execute only that runlevel. Meaning that depending the runlevel you can boot up with a different set of programs...
The rc0.d,rc1.d,... directories in /etc
1,347,271,313,000
I created a startup script to start/restart/stop a group of applications. I used the lib /etc/init.d/functions in my script. It is working well on my system, but it not working for my client; he is getting the error: No such file or directory /etc/init.d/functions Right now I don't know which linux distro my client ...
It's specific to whatever distribution you're running. Debian and Ubuntu have /lib/lsb/init-functions; SuSE has /etc/rc.status; none of them are compatible with the others. In fact, some distributions don't use /etc/init.d at all, or use it in an incompatible way (Slackware and Arch occur to me off the top of my hea...
No such file or directory /etc/init.d/functions
1,347,271,313,000
I am learning command line from a book called "Linux Command Line and Shell Scripting Bible, Second Edition." The book states this: Some Linux implementations contain a table of processes to start automatically on bootup. On Linux systems, this table is usually located in the special file /etc/inittabs. Other sys...
Let's forget init.d or rcx.d and keep things very simple. Imagine you were programming a program whose sole responsibility is to run or kill other scripts one by one. However your next problem is to make sure they run in order. How would you perform that? And lets imagine this program looked inside a scripts folder fo...
What's the connection between "/etc/init.d" and "/etc/rcX.d" directories in Linux?
1,347,271,313,000
It is not quite official but it looks like systemd is coming to Debian and after reading some of the heated mailing list discussion on that decision, I am curious about the polarizing nature of systemd among linux users. I run Debian (sysvinit) and Gentoo (OpenRC) systems and know nothing concrete about systemd, thou...
Probably everything you want to know is here on the "Debate Init System To Use" pages that the Debian project put together around making the decision of which initsystem to go with. Within that page is a separate link to each of the choices of initsystems. Debate initsystem upstart Debate initsystem systemd For a pr...
What sets systemd apart from other init systems?
1,347,271,313,000
Whenever I try to install something using apt-get I get the error messages involving insserv. I have tried install many different packages but everything give same error. And apparently, CUPS package is doing/has done something because every error message involves it. The following are the errors displayed when I ran ...
First of all, the problem is that you are stuck at the boot sequencing. The boot sequencing method is decided during installation or upgrades. If there are no loops in the dependencies declared by the LSB headers of all installed init.d scripts and no obsolete scripts, the system is converted to dependency based boot...
unable to install anything using apt-get because of insserv
1,347,271,313,000
I am trying to run MongoDB on a Debian 8.5 machine. When I installed the package (pre-built from percona.com), I noticed the following files: /etc/init.d/mongod (1) /lib/systemd/system/mongod.service (2) I understand that /etc/init.d/mongod is called at boot, or in other particular system states, as long as it is reg...
When you have both an init.d script, and a systemd .service file with the same name, systemd will use the service file for all operations. I believe the service command will just redirect to systemd. The init.d script will be ignored. Use systemd. It's new in Debian 8, but it's the default. Systemd service files a...
Confused about /etc/init.d vs. /lib/systemd/system services
1,347,271,313,000
Is ubuntu's /etc/init.d directory exactly equivalent (functionally) to what I presume to be the more standard /etc/rc.d/ (at least on arch)? Is there any particular reason canonical used init.d instead of rc.d for startup scripts?
Ubuntu uses /etc/init.d to store SysVinit scripts because Ubuntu is based on Debian and that's what Debian uses. Red Hat uses /etc/rc.d/init.d. I forget what Slackware uses. There just isn't a standard location. Ubuntu briefly switched from SysVinit to Upstart, but has now turned to using systemd.
/etc/rc.d vs /etc/init.d
1,347,271,313,000
I was going through a tutorial on setting up a custom initramfs where it states: The only thing that is missing is /init, the executable in the root of the initramfs that is executed by the kernel once it is loaded. Because sys-apps/busybox includes a fully functional shell, this means you can write your /init ...
init is not "spawned" (as a child process), but rather exec'd like this: # Boot the real thing. exec switch_root /mnt/root /sbin/init exec replaces the entire process in place. The final init is still the first process (pid 1), even though it was preceded with those in the Initramfs. The Initramfs /init, which is a B...
Can the init process be a shell script in Linux?
1,347,271,313,000
What is the reason for the root filesystem being mounted ro in the initramfs (and in initrd). For example the Gentoo initramfs guide mounts the root filesystem with: mount -o ro /dev/sda1 /mnt/root Why not the following? mount -o rw /dev/sda1 /mnt/root I can see that there is a probably a good reason (and it probab...
The initial ramdisk (initrd) is typically a stripped-down version of the root filesystem containing only that which is needed to mount the actual root filesystem and hand off booting to it. The initrd exists because in modern systems, the boot loader can't be made smart enough to find the root filesystem reliably. Th...
Why does initramfs mount the root filesystem read-only
1,347,271,313,000
I'm confused as to which is best and in which circumstances: invoke-rc.d apache2 restart or service apache2 restart Is there a real difference? man service has the following interesting bit: service runs a System V init script in as predictable environment as possible, removing most environment variables and with c...
The official Debian wiki page on daemons says to use service: # service ssh restart Restarting OpenBSD Secure Shell server: sshd. Functionally service and invoke-rc.d are mostly equivalent, however: invoke-rc.d is the preferred command for packages' maintainer scripts, according to the command's man page service has...
Should "invoke-rc.d" or "service" be used to restart services?
1,347,271,313,000
I managed to create a small and fully functional live Linux CD which contains only kernel (compiled with default options) and BusyBox (compiled with default options + static, all applets present, including /sbin/init). I had no issues to create initrd and populate /dev, /proc and /sys and also I had no issues at all w...
OK, I did a lot of extensive research and I found out what was wrong. Let's start one by one: When we use initramfs boot scheme the first process which the kernel invokes is the /init script. The kernel will never try to execute /sbin/init directly. /init is assigned process identifier 1. This is very important! The...
Minimal Linux with kernel and BusyBox: /etc/inittab is ignored, only /init is executed
1,347,271,313,000
I found lots of good documentation for ubuntu's start-stop-daemon and there is a man page for a binary daemon. But from what I can tell the canonical way to start a daemon in a rhel/centos script is to source /etc/init.d/functions then use the daemon() function. But I can't find any good examples or documentation. Wh...
The documentation and example you are looking for is located at /usr/share/doc/initscripts-*/sysvinitfiles on CentOS/RHEL. Here is the documentation for the daemon function specifically: daemon [ --check ] [ --user ] [+/-nicelevel] program [arguments] [&] Starts a daemon, if it is not already running...
what is the canonical way to start a daemon in rhel/centos-6 init script?
1,347,271,313,000
I've got a shell script, which is essentially a one liner with some logging, which I'm trying to run this from an init script. I'm using the daemon function inside of /etc/init.d/functions to run it, as Redhat does not appear to have start-stop-daemon available. When I call the init script (/etc/init.d/script start) i...
I found a script at http://www.linuxforums.org/forum/programming-scripting/190279-daemon-etc-init-d-functions-does-not-return-launching-process.html#post897522 which I was able to modify to suit my needs. It manually tracks the PID and creates a PID file using pidof. I ended up having to modify this to use pgrep as pi...
How can I run a shell script as a daemon under Redhat?
1,347,271,313,000
I want to create an unprivileged user to run my RhodeCode server and Celery daemon on a CentOS instance. I think the accepted definition of this is no home directory, login disabled, and no shell access? Looking over the man page for adduser I just don't see an intuitive method for doing this. Any suggestions are a...
From here (centos.org) useradd (which is the actual binary the runs when you call adduser, it just behaves differently. See here about that.) has an flag -r which is documented as follows: -r Create a system account with a UID less than 500 and without a home directory Which sounds like what you want to do.
How to create an unprivileged user in CentOS?
1,347,271,313,000
I'm quite new in Linux world, and now I'm trying to understand FHS principles. In /var/run I found about ten *.pid files like crond.pid which contain just PIDs. There are more than ten processes running in the system and just ten files. So what is their purpose and what generated them?
The purpose of these files is to provide an easy means for other processes to communicate with them (e.g. send signals). This only makes sense for long running services, that’s why you find much less such files than processes running. Usually those files are created by the service they represent, you will find a param...
What is the meaning/purpose of *.pid files in /var/run
1,347,271,313,000
I use socat with following init script on debian 7.2 with sysVinit. It works perfectly: #!/bin/bash DESC=socat DAEMON=/usr/bin/socat LIB=/usr/lib/socat SOCAT_ARGS="-d -d -lf /var/log/socat.log" [ ! -f /etc/default/socat.conf ] || . /etc/default/socat.conf . /lib/lsb/init-functions PATH=/bin:/usr/bin:/sbin:/usr/sbin...
Just figured out that I have to use Type=forking like described in http://www.freedesktop.org/software/systemd/man/systemd.service.html. If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is ...
Migrate socat init script to systemd
1,347,271,313,000
I have been using Linux after almost 5 years and observed that boot process has been almost abstracted. I mean, not much is visible to the user what is going on behind the scenes (Due to splash screens etc). Now, this might be good for the end users but not for the geek :) I want to bring back the verboseness of old t...
You can pass --verbose on the kernel command line (replacing quiet splash) to make upstart more verbose. See Upstart debugging. You can put console output in the global configuration file /etc/init.conf so that every job has its stdout and stderr connected to the console (by default, they're connected to /dev/null). (...
Removing abstraction from Ubuntu boot process
1,347,271,313,000
I put the following script in /etc/init.d/rc3.d on my Debian 7 but it doesn't work on my computer #! /bin/sh # . /etc/rc.d/init.d/functions # uncomment/modify for your killproc case "$1" in start) echo "Starting noip2." /usr/local/bin/noip2 ;; stop) ...
Two steps for you to solve this. Your script (/etc/init.d/noip2) should look like: #! /bin/sh # /etc/init.d/noip2 # Supplied by no-ip.com # Modified for Debian GNU/Linux by Eivind L. Rygge <[email protected]> # Updated by David Courtney to not use pidfile 130130 for Debian 6. # Updated again by David Courtney to "LSB...
Run automatically Noip2 when the machine is booted?
1,347,271,313,000
I'm trying to add Qemu to my continuous integration pipeline to test various initrd artifacts. I've already discovered that I can run Qemu like this: qemu-system-x86_64 \ -machine q35 \ -drive if=pflash,format=raw,file=OVMF_CODE.fd,readonly \ -drive if=pflash,format=raw,file=OVMF_VARS.fd \ -kernel vmli...
I've got something that's working: Configure (and build) the kernel with CONFIG_PVPANIC=y; this produces a kernel with compiled-in support for the pvpanic device. Invoke qemu-system-x86_64 with the -device pvpanic option; this instructs Qemu to catch (and exit on) a kernel panic. A kernel panic causes qemu-system-x8...
Can I make Qemu exit with failure on kernel panic?
1,347,271,313,000
I have a init script in /etc/init.d/myservice for initialize a service like this: ... start() { ... daemon /usr/sbin/myservice ... } stop() { ... pgrep myservice pidof myservice ps -ef | grep myservice ... } And when I try to stop the service, this is the output: 10000 10001 10000 root 10000 ...
pidof = find the process ID of a running program Pidof finds the process id's (pids) of the named programs. It prints those id's on the standard output. This program is on some systems used in run-level change scripts, especially when the system has a System-V like rc structure. sysadmin@codewarden...
Why pidof and pgrep are behaving differently?
1,347,271,313,000
Is there any real difference between /etc/init.d/networking restart and invoke-rc.d networking restart (Debian)?
What invoke-rc.d does is documented in its man page. It is a wrapper around running the init script directly, but it also applies a policy that may cause the command not to be run, based on the current runlevel and whether the daemon should be run in that runlevel. By default, Debian does not differentiate between run...
Difference between /etc/init.d/networking restart and invoke-rc.d networking restart
1,347,271,313,000
I have several questions related to non-interactive, non-login shells and cron jobs. Q1. I have read that non-interactive, non-login shells only "load" $BASH_ENV. What does this exactly mean? Does it mean that I can point $BASH_ENV to a file, and that this file will be sourced? Q2: Assuming that I have an entry in c...
For Q1 & Q2, see here. Q3 is answered in the discussion of your other three questions below. WRT $BASH_ENV, from man bash: When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the ...
BASH_ENV and cron jobs
1,347,271,313,000
After trying to delete apache and tomcat, and now trying to reinstall apache 2, I am missing the init.d/apache2 file to start/stop my server. I am not sure if the new install actualy worked, and my apt-get purge apache2 didn't remove everything in the first place! How can I get the init.d/apache2 file to test if serv...
Try using apt-get install --reinstall apache2 to force the apt-get system to install again even though the package exists and overwrite current files — even the ones it thinks are already there. By manually deleting things from the system you undoubtedly have the package manager confused about what needs doing where. ...
Missing init.d/apache2 file [duplicate]
1,347,271,313,000
So I have this program which I manually run as root : sudo gammu-smsd -c /etc/gammu-smsdrc -d What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up . Is it ok to just edit root's crontab and stick this command there?...
How about /etc/rc.local? This will be executed last in the startup sequence.
How to run a program on boot up?
1,347,271,313,000
CPU is AMD GX-412TC SOC: GX-412TC GE412TIYJ44JB 4 6W 2MB 1.0GHz/ 1.4GHz N/A N/A DDR-1333 0-90°C which does not have rdrand: grep rdrand /proc/cpuinfo # nothing I see following messages in my syslog after machine boot: kernel: random: dd: uninitialized urandom read (512 bytes read) kernel: random: cryptsetup: uninit...
For haveged to work, it has to be compatible with your kernel — there's an issue with haveged not doing anything in kernel versions >=5.x, see is haveged still useful/relevant? #57 on GitHub. The maintainer was kind enough to re-introduce functionality but those patches will have to be released and then make it into t...
syslog message at boot: uninitialized urandom read
1,347,271,313,000
I had to write my own CentOS init.d script for celery because it only ships with one for Debian. You can see the script I wrote when I answered my own stack overflow question 3989656. But there's a problem with this script. if I invoke it: sudo service celeryd start then I need to hit enter to get a shell prompt afte...
Had the exact same problem - your question and investigations actually helped me find the answer. Start celery with celery_detach - and, poof! Things work! ie. manage.py celery_detach --params --settings=foo It returns immediately, with a proper line break, and the things that fabric is looking for.
Why do I need to hit enter to get my shell prompt after my init.d script completes?
1,347,271,313,000
I'm using a Raspberry Pi B, with Raspbian. After upgrading to Jessie, watchdog daemon doesn't start at boot anymore. Starting it manually using "sudo service watchdog start" does work. I tried: purging and reinstalling watchdog update-rc.d watchdog defaults && update-rc.d watchdog enable systemctl enable watchdog pro...
Open /lib/systemd/system/watchdog.service and add [Install] WantedBy=multi-user.target Systemd needs the [Install]-Section for a Unit to know how it should enable/disable the Unit.
Watchdog daemon doesn't start at boot
1,347,271,313,000
I would like to migrate some OpenRC init script to systemd but I think that it is general problem of environment variables handling in systemd. Original OpenRC files There is a file e.g. /etc/conf.d/fooservice with contents # value of FOO variable # you can override default value by uncomenting this line # FOO=value1...
systemd is not a shell, so it does not support shell-specific substitutions in environment files. Their format is simply KEY=VALUE, with possible empty lines and comments in between. To quote systemd.exec(5): Settings from these files override settings made with Environment=. If the same variable is set twice from th...
systemd: default value for environment variable
1,347,271,313,000
I'm running Debian wheezy. Many scripts in /etc/init.d/ use various logging functions defined in the Linux Standard Base, like log_success_msg and log_warning_msg. The LSB documentation seems a bit ambiguous as to exactly what these functions should do: The log_success_msg function shall cause the system to write a...
It looks like the solution is to install bootlogd and put BOOTLOGD_ENABLE=yes in /etc/default/bootlogd. References: bootlogd - Debian Wiki bootlogd(8) man page bug 524761 - rsyslog doesn't log boot messages (boot.log) bug 658134 - no more bootlogs
How to write init.d script log messages to disk?
1,347,271,313,000
Is there a way to run a script on shutdown, after the file system is remounted as read-only? I've a raspberry pi connected to a wireless socket, which I can control via a sender and a script. I want to power off that socket (powering off the raspberry) on shutdown, after the file system is mounted read-only. I've trie...
I found a reliable solution: Just put the script in /usr/lib/systemd/system-shutdown/. See also: https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shu...
systemd: running a script on shutdown after filesystems are mounted read-only
1,347,271,313,000
In order to adjust the screenpad backlight on my ASUS Zenbook, I am using a kernel module I found here. Per his instructions, to make keybind shortcuts using a simple screenpad x command to adjust the brightness, I need to add sudo chmod a+w '/sys/class/leds/asus::screenpad/brightness' to 'rc.local', as the command is...
If your system is using systemd, that is your best option for what you want to do. The systemd unit will already be executed as root, so sudo is not needed, and you can set it up to run during bootup without even needing anyone to be there to log in. Here's one link with information on systemd: https://www.digitalocea...
Running a sudo command automatically on startup
1,347,271,313,000
I have a an inittab file with the following entry: console::askfirst:-/bin/ash According to this Man page a '+' character in the process field means init will not do utmp and wtmp accounting for that process. However, it does not say anything about a '-' character. What does having the '-' character in the process ...
The hyphen appears to be a Busybox-specific feature (as is "askfirst", which was how I found that you are using Busybox). The example inittab file says: # /bin/sh invocations on selected ttys # # Note below that we prefix the shell commands with a "-" to indicate to the # shell that it is supposed to be a login shell....
inittab '-' character in process field
1,347,271,313,000
On my Debian server, I have no network shares (NFS, SMB, ...). I am trying to optimize and simplify my boot process. Is it OK to remove the following init scripts? /etc/rcS.d/S12mountnfs.sh /etc/rcS.d/S13mountnfs-bootclean.sh AFAICT, these are only needed, when NFS is to be mounted. However, I am not sure what purpos...
You won't really optimize anything by removing these scripts. The time they take is negligible. The *-bootclean.sh scripts clean up files that must or should not survive a reboot: files in /var/run, /var/lock, /tmp, etc. In Debian with SysVinit, there are three such scripts: checkroot-bootclean.sh runs just after the...
Removing unused init scripts
1,347,271,313,000
Are there any standards for aliasing sudo /etc/init.d/? I'm sure many people have considered cutting down these 17 characters to just 2 or so.
On Linux with SysVinit (the traditional init implementation), the service command is a shell script that calls a script in /etc/init.d. sudo service wibble restart service also knows to look for Upstart jobs if available. Upstart also comes with start, stop, reload and restart commands. sudo restart wibble I recomme...
Aliases for 'sudo /etc/init.d/'
1,347,271,313,000
I'm using apache2 and postgres running on Ubuntu Server 10.04. I have removed the startup scripts for both of these apps and I'm using supervisor to monitor and control them. The problem I have run into is that both of these need directories in /var/run (with the correct permissions for the users they run under) for p...
In reply to this comment: There are currently no startup scripts for the servcies. The supervisor daemon is started by the init.d scripts and then the other services are started by this service, which should not run as root. If your supervisor is started from init.d script, then just create another init.d ...
Create directory in /var/run/ at startup
1,347,271,313,000
I know that rc*.d directories are used at startup, or reboot, or so on time, for starting or stopping programs. Can anybody explain me what's the difference between the rc*.d folders placed under the /etc/ path and the other placed under the /etc/rc.d/ path. Also, what's the difference between /etc/init.d and /etc/rc...
Nothing. Different Linux distributions, and the LSB, had different standards, so both are present on CentOS to make it easier to run software from different versions. One is just a symbolic link to the other. http://www.centos.org/docs/5/html/5.1/Installation_Guide/s2-boot-init-shutdown-init.html gives details on th...
What's the difference between /etc/rc.d/rc*.d and /etc/rc*.d
1,347,271,313,000
I just have a simple question but scouring the search engines I have not found any explanation of what the - (hyphen) in the chkconfig runlevel actually stands for within the init script file. For example in /etc/init.d/mysqld the first few lines are like this: #!/bin/bash # # mysqld This shell script takes ca...
The hyphen (-) found in an init script: #!/bin/sh # # chkconfig: - 24 73 means that the service should not be started in any run levels by default, only stopped. It replaces a list of run levels (e.g. 345) as shown below: #!/bin/sh # # chkconfig: 345 24 73 Therefore if you use: chkconfig --add <script> then no st...
What does the hyphen mean in chkconfig run level in an /etc/init.d script?
1,347,271,313,000
Is there some tool that displays all available init scripts (on Debian), short of one having to remember a location like /etc/init.d, not to mention that not everything in there is an init script?
The chkconfig utility can do this. Unlike RHEL or SLES, it does not come installed by default in Debian, but it is a good end-user tool for sysvinit configuration. To list all sysvinit services: chkconfig --list
Displaying all sysvinit init scripts
1,426,114,625,000
My script is not running on boot in a vagrant box under Ubuntu. My script looks like this - #!/bin/bash # /etc/init.d/mailcatcher ### BEGIN INIT INFO # Provides: scriptname # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start...
And now for the Ubuntu answers. This is an Ubuntu Linux question, and version 15 is now released. The Ubuntu world now has systemd. But even before version 15 the Ubuntu world had upstart. There really isn't a reason to write System 5 rc scripts; and there is certainly no good reason for starting from there. Both u...
init.d script not being run on boot
1,426,114,625,000
I'm trying to track down some quirkiness with a Java application that misbehaves when launched via a startup script in /etc/init.d , but runs fine when you open a GUI terminal window and run it through /etc/init.d/myapp start. (The quirkiness involves a portion of the app that does some hacky handwaving with X.) Since...
If your application needs an X server for some weird reason but doesn't do anything useful with it, give it a virtual X server. This is commonly done to run web browsers in automated test suites for web applications — nobody's looking at the screen but the web browser won't run without one. Xvfb creates an X server th...
How to make /etc/init.d script act like it's launched under X?
1,426,114,625,000
I'm currently exploring creating a startup script in the form of a system process located in the /etc/init.d/ on my Fedora 14 Linux installation. It sounds like the following two lines are bare minimum requirements? #!/bin/bash # chkconfig: 345 85 15 (however on this one I've seen different combos) What's the purpose...
Look at the docs file /usr/share/doc/initscripts-*/sysvinitfiles (On current F14, /usr/share/doc/initscripts-9.12.1/sysvinitfiles). There's further documentation here: http://fedoraproject.org/wiki/Packaging/SysVInitScript. The chkconfig line defines which runlevels the service will start in by default (if any), and ...
Are certain parts of startup scripts necessary or just good practice?
1,426,114,625,000
To ask my question, I must first clarify the context. Every init script in /etc/init.d (on RedHat and Centos distros) is prepared to be managed with the chkconfig command-line tool utility. This tool manages the symlinks in /etc/rc[0-6].d, understand runlevels and permit to add and remove init scripts from the set th...
The documentation for these directives is in /usr/share/doc/initscripts-*/sysvinitfiles. Except for "Author", which is non-standard.
What are the chkconfig directives (classic style) into init.d scripts?
1,426,114,625,000
I am trying to run agetty in a runit based linux system, but I have the following problem sh: cannot set terminal process group (136) Inappropriate ioctl for device sh: no job control in this shell I have no clue about this error, do you have some ideas The script for running agetty is #!/bin/sh exec /sbin/agetty 38...
Use setsid as follows. #!/bin/sh exec setsid /sbin/agetty 38400 tty1 linux --noclear The setsid wrapper will start agetty as a session leader (see this answer), allowing it to bind to tty1. You can see the different behavior from the following example ps. # ps xao pid,ppid,sid,tty,cmd [...] 150 1 150 ? runsvdir ...
Error trying to run agetty in a runit based linux installation
1,426,114,625,000
Here is my rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. /...
/etc/rc.local is executed before the X server starts, so it has no access to any GUI features. The xrandr commands cannot have any effect. Put the xrandr commands in a different file, which runs when your GUI session starts. The file depends on your desktop environment.
Why doesn't rc.local run entirely
1,426,114,625,000
I have a init script which is poorly designed because it does not conform to the Linux Standard Base Specifications The following should have an exit code of 0 if running, and 3 if not running service foo status; echo $? However because of the way the script is designed, it always returns a 0. I can not fix the scr...
You are piping the grep output to wc and echo $? would return the exit code for wc and not grep. You could easily circumvent the problem by using the -q option for grep: /etc/init.d/foo status | /bin/grep -q "up and running"; echo $? If the desired string is not found, grep would return with a non-zero exit code. EDI...
How to trick an init script into returning 0
1,426,114,625,000
I'm trying to write a cron job script that will check if my services are running and restart them if they aren't so I don't have to do it manually. Now, I've looked up online how to check the status of a service in a bash script, and have found basically the following, with a few variations: ps auxw | grep <service_n...
Not 100% of the time. However, it's a very good yardstick. CFEngine 3 uses this in "services promises" to check if services are running. If the exit code of /etc/init.d/<servicename> status is zero, it assumes the service is running. I have just run into BitBucket's noncompliance with this convention: /etc/init.d/at...
Does an init script always return a proper exit code when running status?
1,426,114,625,000
I am experiencing strange behavior with LSB Init Scripts in Debian Wheezy. I can demonstrate the problem on following example: The script /etc/init.d/resolvconf starts in S and stops in runlevels 0 and 6. # Default-Start: S # Default-Stop: 0 6 And indeed, when I use chkconfig resolvconf on to turn the script...
chkconfig only reads the "Default-Start" lines when calculating the runlevels for scripts. It counts the number of runlevels and only calls insserv if at least one runlevel is requested in "Default-Start"... Workarounds which avoid this behaviour include: enabling services with chkconfig -a; disabling services with c...
confusing behavior of LSB Init Scripts in Debian
1,426,114,625,000
I have writen my own initscript /etc/init.d/myscript. I can start and stop my script with the service command service myscript start service myscript stop When I type service <TAB>, bash_completion displays all my initscripts from /etc/init.d/, including myscript. But when I type service myscript <TAB> nothing happen...
On older versions of bash-completion, like the one available for CentOS on the EPEL repository, there are individual scripts for sysvinit services in /usr/share/bash-completion/. In this case you may want to add additional scripts there based on an example like the cups completion. On newer systems, like my Fedora 19,...
bash_completion for initscripts
1,426,114,625,000
Background: I use Debian Lenny on an embedded device uname -a Linux device 3.4.0 #83 Sun May 26 17:07:14 CEST 2013 armv4l GNU/Linux I have a C code (say my_C_program) that calls a board specific binary file (via system("spictl someparameters") ) called spictl to use SPI interface user:~# ls -al /usr/local/bin/spict...
You're C executable probably requires some environment variables to be set to function. For example the env. variable $PATH or $LD_LIBRARY_PATH. There also other variables such as $HOME which won't be set until a user has logged in. This last one might be necessary for your app to access config files and/or log files,...
why do I have two different results if I run a program through terminal(as root) or /etc/init.d(or /etc/rc.local)
1,426,114,625,000
I am manually tweaking Debian init scripts in order to optimize the boot time of an embedded device. So far I reduced it by half just with the "low hanging fruits" ie. the smaller scripts that are easy to understand. Now I am left with a few init scripts that take about 20s to run in total. Based on the experience fro...
You could do something like this. I've only lightly tested it but I think the general concept is sound. Example Say you have the following directory of files: $ ls -l total 16 -rwxrwxr-x 1 saml saml 268 Oct 4 17:44 expander.bash -rw-rw-r-- 1 saml saml 18 Oct 4 16:49 src_1.bash -rw-rw-r-- 1 saml saml 20 Oct 4 16:5...
Flatten shell script (include sourced scripts) and remove unused functions
1,426,114,625,000
I want to create a bootup script that runs before the root filesystem / has been mounted as I want to use dm-cache to cache it. The script is supposed to contain cache setup commands. Where would I need to put such a script and what format does it need to have? I cannot find any useful documentation by googling. Runni...
Going by the instructions on the dm-cache github, to create a cache you need the kernel modules dm_mod and dm_cache loaded (assuming you already have a patched kernel) Also you will need to access the dmsetup executable and presumably you want /dev to be populated so you can access the device on which you will create ...
How to write a pre-mount startup script?
1,426,114,625,000
I tried to display the list of startup scripts for the current runlevel at bootup. I wrote the following code. rl=`runlevel | cut -d " " -f2` ls /etc/rc.d/rc$rl.d/S* | cut -d "/" -f5 sleep 10 It's working if I put this code in rc.local file. But it's not working if I put it in rc file or in a separate script file ab...
rc is typically not used by Linux distributions but is used in BSD rc.local is used to be able to execute additional commands during the startup without having to add symlinks. rc.sysinit seems to be Red Hat specific and is executed very early in the process. It is executed as one of the first scripts while rc.local...
What is the difference between rc, rc.local and rc.sysinit?
1,426,114,625,000
I have an authoritative DNS daemon in my test DNS setup which is responsible to provide host IP at best choice. This daemon/process can run by setting some capabilities using setcap and then a development user can start or stop this without becoming the root user or using sudo. But while booting up the box, this daemo...
You could use su in your startup scripts: su -s /bin/sh -c '/usr/bin/somedaemon' someuser Another solution would be to start the daemon using cron.
possibility of running daemons with under privileged users during bootup
1,426,114,625,000
I am just going through the service-list of a server (CentOS 5) - the question will probably apply to other RedHat, Fedora, ... versions, too. Note that my servers normally run in runlevel 3 (no GUI server processes started). I stumbled across two services: readahead_early readhahead_later These two services get the...
The idea is to load these files into cache before they're needed, so that there is no need to wait for them when X is trying to start. Obviously, there isn't much point in doing this for files that aren't actually needed in the system's day-to-day operation, so for example caching the X server itself is counterproduct...
Can readahead-services be safely disabled?
1,426,114,625,000
I'm not sure what the general methodology of daemonizing a script is. For example, I've searched online and if I was trying to write a python script that checked the time every second on my computer, all I could think of is using systemd to start it up and then in Python write the script within a never ending loop wi...
systemd is not a catch-all. It won't be the solution to every problem, however it does give you a lot of tools to help you solve problems. The usefulness of those tools comes down to how well you can use them. Let's look at a very basic service file check-time.service (note that I created this service file by hand, us...
What are ways of creating a daemon using systemd? [closed]
1,426,114,625,000
When I boot my system, I can see the boot messages on my physical console tty1. After my X server has started, I can switch back to tty1 with CTRLALT+F1, and still see the output on the console. There is no getty running, because I have commented out the following line in /etc/inittab: #1:2345:respawn:/sbin/getty 384...
It's not possible and it has never been possible AFAIK. This is well explained in the Linux keyboard and console HOWTO: the console display history uses the video memory witch is flushed when you switch console. Upon changing virtual consoles, the screen content of the old VT is copied to kernel memory, and the scree...
cannot scroll back in console (tty1)
1,426,114,625,000
At the top of files in /etc/init.d are comments like the following. ### BEGIN INIT INFO # Provides: ntp # Required-Start: $network $remote_fs $syslog # Required-Stop: $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: Start NTP daemon ### END INIT INFO What is t...
The LSB info is parsed by insserv on older Ubuntu and Debian systems, and by chkconfig on older Redhat and Fedora systems, and is now parsed by /usr/lib/systemd/system-generators/systemd-sysv-generator on systems using systemd. All of these are coded in C. The pre-systemd chkconfig sources in the above link are pro...
What is it that parses the LSB information in init scripts?
1,426,114,625,000
On a system that uses SysV init run levels such as Centos 5, when the OS is booting, does it go straight to the run level defined in /etc/inittab? If I change my run level using the init command do the kill scripts for my current run level execute and then the start up scripts for the new run level execute? For exampl...
Yes, SysVinit goes straight to the chosen run-level on boot without looking at scripts in other levels. You can view the runlevel history using the runlevel command. On first boot, it will show the "previous" runlevel as 'N'. After a runlevel change it will show the previous and current runlevel. When switching runlev...
SysV init run levels
1,426,114,625,000
I've just started playing with Debian 6.0 (Squeeze) in a VPS environment, as a way to learn more about system administration. One thing I'd like to configure is a default packet filtering policy. (Permit new and established SSH inbound, permit rate limited ICMP inbound, drop everything else inbound, permit anything ou...
There is no default standart way to setup a firewall in Debian, except maybe calling a script with a pre rule in the network configuration (/etc/network/interfaces) but there are many packages providing different ways to do it. For example the packages uruk and iptables-persistent provide very simple scripts to load a...
Is there a standard way to configure what policy iptables loads on startup under Debian?
1,426,114,625,000
I want to have radvd (the IPv6 router advertisement daemon) run on startup on Fedora 13. However, the network interface that it will use must be up, otherwise the daemon won't start. If I run the daemon manually when the system is running everything works fine. However, I can't figure out how to tell the Fedora 13 ini...
I am not too familiar with Fedora, but I know network manager does have a built-in system to run scripts after an interface comes up. On Arch linux the scripts are located at /etc/NetworkManager/dispatcher.d You will need to create a script to say when the interface is up, do this, when the interface is down do this...
Run daemon on startup in Fedora 13 after wireless interface is up
1,426,114,625,000
While learning the Network Teaming objective of the RHCE (RHEL7) exam I noticed that examples use DEVICETYPE directive in the ifcfg scripts for master and port interfaces. I knew there was TYPE directive that I've seen in other ifcfg scripts before. The question arisen was what's the difference between those two direc...
After checking man pages, initscripts (package owning ifcfg scripts) documentation in /usr/share/doc/initscripts-*/sysconfig.txt, initscripts mailing list, and several bugs from redhat's bug tracker the only thing I understood is that to avoid problems those two directives should not be used in the same ifcfg script. ...
What's the difference between TYPE and DEVICETYPE directives in ifcfg scripts?
1,426,114,625,000
I've written a simple init script to start and stop a Python script as a service. I have to be explicit about the version of Python I'm running, because this is on a CentOS 5 box with Python 2.4 & 2.6 installed (both via yum). Here's what I have so far: #!/bin/sh # chkconfig: 123456 90 10 workdir=/usr/local/bin/Foo ...
I may be missing something but I don't understand why you are fiddling with grep in the first place. That's what pgrep is for: #!/bin/sh # chkconfig: 123456 90 10 workdir=/usr/local/bin/Foo start() { cd $workdir /usr/bin/python26 $workdir/Bar.py & echo "FooBar started." } stop() { pid=`pgrep -f '/Ba...
Grepping a variable
1,426,114,625,000
I'm running a raspbian (based on debian). I want to change the priority of the init services so the very first script which is run by init is one made for me. How can I do it? On runlevel S I have 3 scripts with priortity 01: hostname.sh, fake-hwclock and mountkernfs.sh. If I just put my script on runlevel S with pr...
The init scripts on /etc/init.d/ specify some information on it's LSB header, which in essence are just some lines at the beginning of the script. The field "Required-Start" of some script allows you to specify services that must be initialized before this script. insserv automatically add init scripts regarding LSB ...
Change init scripts priority
1,426,114,625,000
I have a bash script in crontab that runs @reboot: The script itself contains a wget command to pull and download a file from the internet When I run my script after signing in and opening the terminal it works and saves the files properly(html, png). But when I reboot my system it saves runs and saves as plain text ...
The issue is almost certainly that your @reboot cron job has started before your network interfaces have come up. This is, in general, a well-documented shortcoming of cron. It doesn't mean the @reboot facility is useless, it just means you need to understand how it works, and how to work around it when it fails - as ...
wget saving files as emply plain text files on boot
1,426,114,625,000
i.e. Using something like IPython, re.pl, or somesuch as a login shell, instead of bash/ksh/etc. Using initscripts, etc. written in Python or some other scripting language, and making no use of shell scripts whatsoever Not having any POSIX-compatible command shell installed In other words I'm thinking of more a Wind...
I believe the Linux kernel does not depend on a POSIX shell, (though will look for the #! line when executing files). I suspect it is possible to have a working Linux system, but most software will expect mostly POSIX-compliance, and desktop software will typically expect most of LSB (Linux Standard Base) compatibilit...
Is it possible to create a Linux environment without a traditional command shell?
1,387,757,805,000
I recently purchased a vps and I attempted to create a startup/restart script to start up my java program. I am running CentOS 6. The script works if I execute it manually with this command: service policyserver start But fails to run automatically, creates a file in the /tmp/test.log with the following error: Sta...
You can debug an issue like this by running the start script in a more verbose manner. $ bash -x service policyserver start You might want to capture this output to a log file too. $ bash -x service policyserver start |& tee policyserver_startup.log You can then go through the log file and see which command is faili...
chkconfig bootup script failing, script runs good manually