Tag Info

Hot answers tagged

18

Bash will interpret a line that has text followed by a = as an assignment to a variable, but it will interpret a line that has text followed by a space as a command with an argument. var=assignment vs command =argument Bash scripts work on the principle that everything in the script is as if you have typed it into the command line. In configuration files ...


7

You can using fstab module. Its documentation here. Example: fstab = Fstab() for entry in fstab.entries: pprint.pprint(entry)


4

This will not work because /etc/fstab file doesn't conform to the format the ConfigParser supports. As man 5 fstab indicates, the /etc/fstab file is a whitespace separated file with 6 columns. The Python ConfigParser is a library for Parsing files commonly known as .ini files that, simplified, consist of sections that contain key/value pairs: ...


4

.bashrc is nothing more than a config file for bash, just like my.cnf, php.ini, httpd.conf or a launchd plist. Each has their own syntax, ranging from the no-space assignment of bash to the XML tag soup of launchd (there's also a binary version :-O ) There are no firm conventions, and you have already discovered the Prime Directive of Unix: Read The Fine ...


3

One of the things to look out for when cloning Linux systems is udev's persistent network device naming rules. udev may create and update the file /etc/udev/rules.d/70-persistent-net.rules to map MAC addresses to interface names. It does this with the script /lib/udev/write_net_rules. Each MAC address (with some exceptions; see ...


3

Some programs offer a check of the configuration file, for example: postfix check Otherwise you could get the original config files from the repositories and compare them with diff to the current.


3

Take a backup as, cp /etc/nsswitch.conf /etc/nsswitch.conf.orignal Now you can use sed -i or open /etc/nsswitch.conf with some editor like vim and do the changes. If error occurs, you can revert back to the original version, cp /etc/nsswitch.conf.original /etc/nsswitch.conf I got this tool suggestion by Ulrich in the chat which is used for editing the ...


2

This task is an example of "configuration management". As you might expect, many other people have also had the same questions as you. The general class of software that performs this function is called configuration management software. Some popular examples are: Chef Puppet SaltStack


2

I would recommend using augtool from augeas. Puppet and other configuration management tools integrate with augeas and allow you the safe and syntactically correct way to manipulate configuration files. Augeas is a tool to transfer configuration files into a tree, which you can query and modify. It ensures that the modification are syntactically correct ...


2

In /etc/default/grub I changed this: GRUB_CMDLINE_LINUX_DEFAULT="text nomodeset acpi_backlight=legacy" to: GRUB_CMDLINE_LINUX_DEFAULT="text nomodeset" update-grub, reboot, and start mdm by hand: /etc/init.d/mdm start No idea why the backlight should suddenly break.


2

Use sudo -E to preserve your environment: $ export FOO=1 $ sudo -E env | grep FOO FOO=1 That will preserve $HOME and any other environment variables you had, so the same configuration files you started with will be accessed by the programs running as root. You can update sudoers to disable the env_reset setting, which clears out all environment variables ...


2

I'll answer that in a more general way - looking a bit at the whole "Unix learning experience". In your example you use two tools, and see the language is similar. It just unclear when to use what exactly. Of course you can expect there is a clear structure, so you ask us to explain that. The case with the space around = is only and example - there are ...


2

The spaces around = sign is always problem when you do an assignment in bash. There is no exception here, you must remove all spaces around = if you want to get a valid simple assignment (no expansion, no arithmetic, no array assignment)in bash. For config file, because each software has its own parser to parsing its config file, bash has no relationship. ...


2

Building on @mark-plotnick 's remark: The new hardware has a different mac address. The old mac address is still hard coded in /etc/udev/rules.d/70-persistent-net.rules. You could simply rename this file. In that case rebooting will recreate the file with the new mac address.


1

Set up sudo to preserve the HOME environment variable. Run visudo to edit the sudo configuration. Make sure that the option always_set_home is not set, and that HOME is present in the env_keep list. Add the following lines: Defaults !always_set_home Defaults env_keep+="HOME" Remove a line like Defaults always_set_home if there is one.


1

If you already use firewall software that fulfils its purpose and that you know how to use, but lacks this facility, I suggest you stick with it. The switch from, or addition to, an application using a single configuration file to a directory whose file contents are taken combined to be the configuration, is often made because of package maintainability. ...


1

I wrote a small python script that takes care of this problem. The logic looks at each line in the file package.accept_keywords and only acts on lines that start with = or <=. These lines have a maximum bound version so we can check if they are needed anymore. Lines without a qualifier or a >= are left as-is as we cannot know if they are obsolete. ...



Only top voted, non community-wiki answers of a minimum length are eligible