Server - Ubuntu: Questions and Answers (2014)

Ubuntu: Questions and Answers (2014)

Server

Skip to questions, Wiki by user jrg

What Questions Should Have This Tag?:

· Questions related to Ubuntu Server (As opposed to Ubuntu Desktop), and the Ubuntu Server core.

· Any questions related to installing services and programs on Ubuntu Server


Some Basic Definitions:

Server - A device on a network which provides "services" to other devices (most commonly file sharing,mail, printing, or shared disk space)

Ubuntu Server - An Operating System (OS) which (through software/hardware) allows the device(s) to perform server functions.


Brief Introduction to the Subject:

Packages and programs that are included in the Ubuntu Server core include web servers, databases, DNS, etc. Some of these programs include:

· Apache 2 web server

· MySQL Database

· Postgre SQL Database

· PHP 5

· Bind 9 DNS Server

These programs can be set up and installed separately from the Ubuntu Server Core, but questions regarding those programs should be tagged with that program's tag.


Important Links for Learning More:

· Ubuntu Server Official Documentation

· How do I set up an email server?

· How do you run Ubuntu Server with a GUI?


Questions

Q: Chkconfig alternative for Ubuntu Server?

Tags: server (Next Q), services (Next Q)

I've become very accustomed to managing service startups on Redhat/RHEL platforms using chkconfig though that doesn't appear to be the Debian/Ubuntu way - How do I update runlevel information for system services on Ubuntu?

Ultimately looking for the equivalents of:

chkconfig --add <service>

chkconfig --level 345 <service> on

chkconfig --del <service>

Tags: server (Next Q), services (Next Q)

User: marco-ceppi


Answer by richard-holloway

The equivalent to chkconfig is update-rc.d

The equivalents you seek are

update-rc.d <service> defaults

update-rc.d <service> start 20 3 4 5

update-rc.d -f <service> remove

See this useful page for more information or check out man update-rc.d


Answer by jokerulez

Best alternative IMHO is sysv-rc-conf To install just need to run the command:

sudo apt-get install sysv-rc-conf

Once installed run the command:

sudo sysv-rc-conf

You can check or uncheck the options to start a service on any level of execution and may even stop or start the services from this console. It is an indispensable tool to enable or disable applications on an permanently way to boot your ubuntu If you need a quick change, then you can use the CLI interface:

For example to stop ssh at levels 3 and 5 of execution:

sysv-rc-conf-off level 35 ssh

Atd to start in runlevels 2,3,4 and 5:

sysv-rc-conf on atd

If you want to know more:

man sysv-rc-conf


Tags: server (Next Q), services (Next Q)


Q: What is LVM and what is it used for?

Tags: server (Next Q), partitioning (Next Q)

As a Linux/Ubuntu newbie, what is LVM and what is it used for?

In terms of a web server installation, what benefits does it provide?

Would you recommend using it?

Tags: server (Next Q), partitioning (Next Q)

User: matthew-blackford


Answer by riccardo-murri

Benefits

You can think of LVM as "dynamic partitions", meaning that you can create/resize/delete LVM "partitions" (they're called "Logical Volumes" in LVM-speak) from the command line while your Linux system is running: no need to reboot the system to make the kernel aware of the newly-created or resized partitions.

Other nice features that LVM "Logical Volumes" provide are:

1. If you have more than one hard-disk, Logical Volumes can extend over more than one disk: i.e., they are not limited by the size of one single disk, rather by the total aggregate size.

2. You can set up "striped" LVs, so that I/O can be distributed to all disks hosting the LV in parallel. (Similar to RAID-0, but a bit easier to set-up.)

3. You can create a (read-only) snapshot of any LV. You can revert the original LV to the snapshot at a later time, or delete the snapshot if you no longer need it. This is handy for server backups for instance (you cannot stop all your applications from writing, so you create a snapshot and backup the snapshot LV), but can also be used to provide a "safety net" before a critical system upgrade (clone the root partition, upgrade, revert if something went wrong).

While being most useful on server systems, I think that features 1. and 3., combined with LVM's ability to create/resize/delete LVs on the fly, are quite handy on desktop systems as well. (Especially if you experiment a lot with the system.)

Downsides

Of course, all of this comes at a price: the initial set-up of LVM is more complex than just partitioning a disk, and you will definitely need to understand the LVM terminology and model (Logical Volumes, Physical Volumes, Volume Groups) before you can start using it. (Once it is set up, using it is much easier, though.)

Also if you use LVM across hard drives you may loose all your data when only one drive fails.

Recommendation

Reccommend reading the LVM HOW-TO from The Linux Documentation Project.


Tags: server (Next Q), partitioning (Next Q)


Q: How do I free up disk space?

Tags: server (Next Q)

My Ubuntu cloud server has left only 900MB of disk space.

I'll just empty the directory /tmp and wondering if there is any other location to clean up.

Tags: server (Next Q)

User: user3215


Answer by oli

sudo apt-get autoremove

That can clean out a lot of guff (old kernels, etc) that have been replaced. You can do a similar thing in Synaptic (load it up and select the status button and then the Auto-removeable option).


Answer by drkenobi

To delete downloaded packages (.deb) already installed (and no longer needed)

sudo apt-get clean

To remove all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repository or that have a newer version in the repository).

sudo apt-get autoclean

To remove unnecessary packages (After uninstalling an app there could be packages you don't need anymore)

sudo apt-get autoremove

To delete old kernel versions

sudo apt-get remove --purge linux-image-X.X.XX-XX-generic

If you don't know which kernel version to remove

dpkg --get-selections | grep linux-image

Source: Limpiando Ubuntu: comandos y programas (actualizacin)


Answer by jet

· show top 10 biggest subdirs in the current dir.

du -sk * | sort -nr | head -10

· use filelight or kDirStat to see where the disk space is going visually

· check if you have old kernels for deletion

ls -lh /boot

· cleaning packages

sudo apt-get autoremove

sudo apt-get autoclean

see list of all installed packages, sorted by size. If you see something big and don't use it - uninstall it

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less

· clean unused language files with translations (there are tons of them)

sudo apt-get install localepurge

· check content of /var/tmp/

du -sh /var/tmp/

· check also

man deborphan

· Search for big files:

find / -type f -size +1024k

or

find / -size +50000 -exec ls -lahg {} \;


Tags: server (Next Q)


Q: How do you restart Apache?

Tags: server (Next Q), services (Next Q), apache2 (Next Q)

I switched from SLES to Ubuntu and now I want to restart my local server. In SLES I used :

rcapache2 restart

but this somehow seems not to work in Ubuntu. :(

How do i restart my Apache?

Tags: server (Next Q), services (Next Q), apache2 (Next Q)

User: jai-puri


Answer by maco

Or sudo service apache2 restart for the way that's borrowed from Red Hat. Or sudo restart apache2 for the shiny new Upstart way.


Answer by riccardo-murri

The recommended way under Ubuntu to start/stop services (not just Apache) is to use the start/stop/reload commands (which really are symbolic links to the initctl program, part of upstart).

For services that use the legacy /etc/init.d scripts, the corresponding script will be called with the correct parameters; for services that use the upstart infrastructure, the appropriate event transition will be signaled to the upstartdaemon via initctl.

So, to start/stop/reload/restart apache on Ubuntu, you can use:

sudo start apache2

sudo stop apache2

sudo reload apache2

sudo restart apache2


Answer by marius-gedminas

Do you want to restart Apache, or do you want to gracefully reload its configuration?

Everyone was answering the first question; you can do the second with

sudo apache2ctl graceful

or

sudo /etc/init.d/apache2 reload

Gracefully reloading is a bit faster, and there's no downtime. There's one caveat: if your apache config files contain an error, the server will silently exit without printing any error messages to the console.


Tags: server (Next Q), services (Next Q), apache2 (Next Q)


Q: Setting up a git server

Tags: server (Next Q)

I've recently set up ubuntu-server on Amazon EC2. I would like to use it as my git server, so I could store my repos there.

So, where can I find some detailed instructions of how to setup git on ubuntu server? All these SSH keys and stuff like that, multiple users, etc.

Tags: server (Next Q)

User: paweł-karpiński


Answer by huygens

You can use the tutorial to install a Git server as aking1012 proposed you or you could just install SSH server on your EC2 instance (probably it would be wise to secure it and change the default port).

Git can be server-less you init your repository and then you access it from remote via SSH. So instructions like this on the Ubuntu Server should do it:

GIT_DIR=project.git git init

cd project.git

git --bare update-server-info

cp hooks/post-update.sample hooks/post-update

Finally install SSH on your server:

sudo apt-get install ssh-server

Now, you should configure SSH to secure it.

It's time to put your project online (the data you already have on your development machine):

git push ssh://<username>@<remote-git-hostname>/path/to/project.git master

And now you can start cloning around. You go on your development machine:

git clone ssh://<username>@<remote-git-hostname>/path/to/dir.git

Check this excellent resource on Git.

And for generating your ssh keys for safer authentication, you can read this article about SSH authentication.


Answer by finley

I recommend a book (free ebook download)

Pro Git by Scott Chacon

Chapter 4 deals with setting up a Git server.

http://git-scm.com/book/en/Git-on-the-Server


Answer by marco-ceppi

For all my Git server setups I use Gitolite which allows for a security granularity of "per-branch" access. Setup is pretty straight forward if you're doing it on a remote server it's as easy as running an interactive script. In addition to this "easy-to-setup" nature it also has a package in Natty and Maverick install gitolite

This won't provide a web frontend like Github, or Gitweb - but you can easily configure and install those on top of something like Gitolite.


Tags: server (Next Q)


Q: Debian Stable vs Ubuntu LTS for Server?

Tags: server (Next Q)

Which is a better platform for a professional use server?

Debian Stable or Ubuntu LTS?

The third party software we plan to use, works on both. Which one is better on it own merits?

Take into account things like the kernel (Ubuntu for example has its own custom kernel for servers), and other Ubuntu specific customizations.

I keep switching back and forth, and I need to decide so I can recommend one or the other to a client. Right now, I think I am going to choose Debian Stable.


Recently, I have had Ubuntu Server Edition 10.04.1 have a few strange issues...

I have Ubuntu setup to do automatic updates via a simple script, and every few months or so, libapache2-mod-php5 gets removed because of conflicting packages... Thereby causing me to loose the php function of the web server.

Debian Stable has not done anything like this.

Tags: server (Next Q)

User: soviero


Answer by oli

Well I don't see why people are making a fuss about the quality of the question. It's clearly a decision that lots of developers will want to weigh up before deploying. And there are clearly some differences that are very relevant to deploying each.


I think the prime consideration and comparison between debian stable and an Ubuntu LTS is security and general package updates.

Debian "stable" releases are supported for a year after the next stable release. So if a stable comes out every two years, and you started on a stable release right at its launch, you get three years of updates:

The security team tries to support a stable distribution for about one year after the next stable distribution has been released, except when another stable distribution is released within this year. It is not possible to support three distributions; supporting two simultaneously is already difficult enough.

You should note that the debian cadence is not guaranteed. Stable releases come out when they're ready. This could mean you get anywhere from 18 months to 18 years of support. This makes it very unpredictable as you won't know when you need to upgrade until you know when the next stable will be finalised.

Compare that to a Ubuntu LTS release, desktop updates are very similar but for the server applications and kernel, you get a mammoth 5 years of support, regardless of any new LTS releases in that time:

A new LTS version is usually released every 2 years. With the v12.04 Long Term Support (LTS) version you get 5 years support for both the Ubuntu Desktop and the Ubuntu Server. There is no extra fee for the LTS version; we make our very best work available to everyone on the same free terms.

This means you should be able to deploy the latest LTS on a box and not have to worry about it not getting security updates (for supported packages) for years and years. When you have more than a handful of servers, or just some applications that can't afford any downtime for testing upgrades, or just don't have the time to spend a day/week testing upgrades, Ubuntu has a large advantage over debian.


Answer by jkrider

To answer your question about Professional/Production use I think there are several key elements that have been addressed but there is one point I feel that is extremely crucial.

Packages and Package Management

This is a key difference between Debian stable and Ubuntu LTS especially if your concerned about longevity, uptime, stability etc.

Ubuntu is released every six months and is based off of the Debian unstable branch which generally means overall newer and more up to date software but at the same time having the disadvantage of being considered basically "unstable" at least in an enterprise context.

Now the LTS release is based mostly on Debian Testing which in Debian terms "represents the state of the upcoming stable release before it is actually considered stable" and although Ubuntu puts a lot of time and effort into making regular and LTS versions as stable as possible after the packages have been pulled from there respective Debian branches, LTS is still based on the Testing branch which in turn is still considered by Debian in its own branch to be not quite ready for Production use or anything approaching mission critical.

And Ubuntu's community of developers simply cannot compete on the same scope or level of Debian which is possibly the largest communal based software ever created.

In basic terms this means Ubuntu LTS being based upon the Debian Testing branch and even with Ubuntus attempts to stabilize and polish their testing packages after they're pulled, does not equal the immense development and maturity of Debian stable and the packages thereof. Debian stable truly is the Golden Standard for rock solid stability.


Answer by bytecode

I stumbled upon this thread whilst googling "ubuntu server stability issues" - searching for answers to my own concerns regarding the stability of Ubuntu server.

I have to admit that I'm a long term Ubuntu fan, particularly on the desktop (Since Breezy).

Box 1: "Fred"

I first deployed Ubuntu server 8.04 on a production machine that has low usage requirements; it's predominantly a "brochure-ware" level webserver with about 4/5 websites, which also acts as an offsite backup repository. Primary packages are Apache2, Mysql, Postgresql, PHP.

It's dual core, has 2 GB RAM, 2x 1GB HDD configured with mdadm as RAID1. Stability wise, it has been great except that it seems to die every 3-6 months for no obvious reason, despite combining through log after log.

I've kept this machine on 8.04, performing occasional updates.

Box 2: "Charlie"

Charlie has been running for a similar lifetime as Fred, and is used as an office based backup and media storage machine, office server monitoring node, network gateway for remote logins, wiki and virtualbox host. Primary packages are: Apache2, postgresql, mysql, PHP, webmin, samba and Virtual box - Non OSE (We needed the headless feature back when that wasn't supported in the OSE).

Hardware wise, Charlie is Quad core, with 8GB RAM, has about 10TB of storage, distributed across a number of sata and ide drives, some of the sata drives comprise a soft RAID5 array, we have a drobo connected over firewire, two external usb drives and another drobo due to be attached.

Charlie started on Ubuntu 8.04, has been upgraded periodically via dist-upgrade and is currently at 10.04.

Sadly, Charlie is as stable as drunk in a brawl.

Charlie has frequent kernel panics, OOM's and requires a reboot every 2-3 weeks. Combing through logs has me scratching my head.

To Summarise

I love Ubuntu server, it's familiar, relatively well laid out, I love aptitude (Which should be the default package manager IMHO, packages/apps such as UFW, Fail2Ban, Denyhosts, logwatch, logrotate etc make administration relatively simple.

But both Ubuntu server boxes have uptimes measured in weeks or months, if we're lucky, and yes, during that time we've changed the hardware and re-installed from scracth, tested the disks, tested the RAM.

By comparison, I have clusters of HP DL360 G5's, DL380 G5's, DL380 G6's where uptime is measured in years, sometimes, 1000's of days.

These are running CentOS - and it doesn't float my boat like UBuntu Server, but it seems so much more stable, yet I don't know whether that's the Hardware or the OS.

Just my two-pence worth.


Tags: server (Next Q)


Q: Disable autostart for a service without uninstalling?

Tags: server (Next Q), services (Next Q)

How can I disable autostart for a service without uninstalling? For example, I'd like to leave tomcat installed, but I don't want it turning on every time I restart.

Tags: server (Next Q), services (Next Q)

User: c.-ross


Answer by hhlp

This should do the trick :

Open terminal (CTRL + ALT + t) and type into

sudo update-rc.d tomcat disable

Basically update-rc.d will modify existing runlevel links for the script /etc/init.d/tomcat by renaming start links to stop links.


Answer by riceball-lee

The disable|enable API is not stable and might change in the future. I suggest you use the following command to remove all the symlinks in /etc/rc?.d/:

update-rc.d -f tomcat remove


Tags: server (Next Q), services (Next Q)


Q: How to add a PPA on a server?

Tags: server (Next Q), ppa (Next Q)

The Server version of Ubuntu does not have the add-apt-repository command. How can i add a PPA to the server without this command?

Tags: server (Next Q), ppa (Next Q)

User: luis-alvarado


Answer by mark-russell

You can simply add the add-apt-repository command. It's part of the python-software-properties package.

sudo apt-get install python-software-properties

Side note: in 11.04 they added a symlink to add-apt-repository so it can be run as apt-add-repository which totally makes more sense to me. Everything else apt starts with "apt".

Second side note: (Tested on 13.10) As the comments below indicated, this may also be necessary:

sudo apt-get install software-properties-common


Answer by jo-erlend-schinstad

Let me teach you how to fish. apt-file enables you to find out which package provides a given file. dpkg -S does the same thing, but only for installed packages. apt-file works whether or not the package has been installed.

So, first you install apt-file: sudo apt-get install apt-file. You then need to update its information, just as you have to with apt-get: sudo apt-file update. Now it's ready for use:

jo-erlend@jedesktop:~$ apt-file search add-apt-repository

python-software-properties: /usr/bin/add-apt-repository

python-software-properties: /usr/share/man/man1/add-apt-repository.1.gz

jo-erlend@jedesktop:~$

So, in this case the next thing to do would be to install python-software-properties.


Answer by broam

Not necessarily the best answer, but will function: the old-fashioned way (pre Ubuntu 9.10, they call it) of editing /etc/apt/sources.list still works. You will also need to get the GPG key on the system manually.

See this page: https://launchpad.net/+help/soyuz/ppa-sources-list.html

Copied here because this eventually will disappear.

On older (pre 9.10) Ubuntu systems

Step 1: Visit the PPA's overview page in Launchpad. Look for the heading that reads Adding this PPA to your system and click the Technical details about this PPA link.

Step 2: Use the Display sources.list entries drop-down box to select the version of Ubuntu you're using.

Step 3: You'll see that the text-box directly below reads something like this:

deb http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main deb-src http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main

Copy those lines.

Step 4: Open a terminal and type:

sudo gedit /etc/apt/sources.list

This will open a text editor containing the list of archives that your system is currently using. Scroll to the bottom of the file and paste the lines you copied in the step above.

Save the file and exit the text editor.

Step 5: Back on the PPA's overview page, look for the Signing key heading. You'll see something like:

1024R/72D340A3 (What is this?)

Copy the portion after the slash but not including the help link; e.g. just 72D340A3.

Step 6: Now you need to add that key to your system so Ubuntu can verify the packages from the PPA. In your terminal, enter:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 72D340A3

(Replace 72D340A3 with whatever you copied in the step 5.)

This will now pull down the PPA's key and add it to your system.

Step 7: Now, as a one-off, you should tell your system to pull down the latest list of software from each archive it knows about, including the PPA you just added:

sudo apt-get update

Now you're ready to start installing software from the PPA!


Tags: server (Next Q), ppa (Next Q)


Q: How do I set up an email server?

Tags: server (Next Q)

My VPS is running Ubuntu, and I'd like to be able to receive email to my domain.

How do I easily set up a mail server to do this?

Tags: server (Next Q)

User: stefano-palazzo


Answer by marco-ceppi

This is how I've setup mail on our production machines. These are the criteria that we needed:

· Email Accounts

· Email Aliases (Forwarders)

· IMAP, POP3, and SMTP

"Easy" (tl;dr)

First, I want to address what would appear to be the easiest solution.

sudo tasksel install mail-server

Several issues with this occurred when we tried this: First it installs Dovecot, which is fine for most, but we've deemed Courier to be the better of the two for our needs. Second, it utilizes Postfix which is great but we also need Exim as it's a more powerful MTA/SMTP server. Third, it installs MySQL - in the configuration I utilize we prefer flat files for configuration as it's one less breaking point. Think what would happen if MySQL crashed for some unknown reason. Otherwise the rest of the packages is pretty straight forward and easy to maintain for a small mail service (think 1-2 email domains total).

Our Configuration

Directory Structure

We stray slightly outside the path of normal configurations but it makes for easier management.

All of our mail is stored in /var/mail/virtual/<domain>/<user>/mail So for future examples I'll be using email@example.com, fwd@example.com, foo@example.com to represent an email address, a forwarder to go to example@gmail.com, and a bad address respectively. In the above example it would be /var/mail/virtual/example.com/email/mail.

I also maintain a list of all the domains on the server in /etc/valiases but more about that later.

Postfix

This is more or less the easy part of the setup. Just install the postfix package.

Exim

Install Exim with apt-get install exim4 exim4-base exim4-config exim4-daemon-heavy Once installed you'll need to edit the exim default configuration to replace or add the following values:

domainlist local_domains = @:localhost:dsearch;/etc/valiases:dsearch;/var/mail/virtual

daemon_smtp_ports = smtp : 587 : 465

MAIN_TLS_ENABLE = yes

(These lines will appear in different parts of the file, replace each accordingly)

Once that's complete rebuild the exim configuration with update-exim4.conf This concludes the changes required for Exim

Courier

Install Courier with courier-base this should install courier-authdaemon, courier-authlib*, courier-imap*, courier-pop*, courieruserinfo, courier-ssl

There honestly isn't much configuration outside the standard. You'll just need to create a user database.

Accounts

Exim and Courier check a few places to see if a login or an incoming email are valid. Exim checks if the domain is listed as a local hostname, or if the domain is in /var/mail/virtual or if the domain is in /etc/valiases.

Creating Email Accounts

I eventually created several tools to streamline this process - but adding a new user goes to the tune of:

mkdir -p /var/mail/virtual/example.com/email

chown -R mail.mail /var/mail/virtual/example.com/

maildirmake /var/mail/virtual/example.com/email/mail

chown -R mail.mail /var/mail/virtual/example.com/

Then add the address to courier userdb - so they can log in

userdb email@example.com set uid=8 gid=8 home=/var/mail/virtual/example.com/email mail=/var/mail/virtual/example.com/email/mail

Make sure to replace the values where appropriate. Also - uid and gid need to be the numerical user/group ids for the mail user.

userdbpw -md5 | userdb email@example.com set systempw

This will prompt you for a password, enter the one you wish to use for the account.

makeuserdb

Finally, generate the userdb hash/shadow files. Restart Courier and test if your changes work:

authtest email@example.com

Should produce something similar to

Authentication succeeded.

Authenticated: email@example.com (uid 8, gid 8)

Home Directory: /var/mail/virtual/example.com/email

Maildir: /var/mail/virtual/example.com/email/mail

Quota: (none)

Encrypted Password: $1$LOLCATS$THISWILLBEAHASH.

Cleartext Password: (none)

Options: (none)

If you see "Authentication FAILED: Operation not permitted" instead edit /etc/courier/authdaemonrc and add authuserdb to the authmodulelist line.

After all tests have been confirmed, restart the various services involved (courier-authdaemon, exim4), open the ports 143, 25, 586, 495, 110 and setup the accounts in your favorite mail client.

Creating email aliases

For each domain you should create a file in /etc/valiases (create if it doesn't exist) with at least the following line:

*: :fail: No user at this address.

What this says: If the incoming mail doesn't match any email account I have on file - then the mail should be failed and bounced with a message: "No user at this address". So all mail sent to say: foo@example.com would be bounced as a failure.

However, we have a few email address we wish to maintain elsewhere - say example@gmail.com - in order to do so we need to create /etc/valiases/example.com and the contents of the file should be as follows:

fwd: example@gmail.com

*: :fail: No user at this address.

That way, even though fwd@example.com doesn't match any email accounts on the server, it matches in the /etc/valiases file and the mail will be forwarded to example@gmail.com - However, foo@example.com will still fail with a "No user at this address" message.


Answer by jo-erlend-schinstad

The easiest way is to run sudo tasksel install mail-server. That will give you an email server with sane defaults. All you have to do, is to answer a few questions. Obviously, you're still able to do manual configurations afterwards if that's necessary, but in most cases it won't be. Just follow the on-screen directions and you should be fine.

Reading up on email services administration is absolutely recommendable though.

Official References:

· https://help.ubuntu.com/10.04/serverguide/C/email-services.html


Tags: server (Next Q)


Q: How do I fix my locale issue?

Tags: server

I am getting this message everytime I do something like starting or stopping a service.

Skip code block

perl: warning: Setting locale failed.

perl: warning: Please check that your locale settings:

LANGUAGE = "en_US:en",

LC_ALL = (unset),

LC_MESSAGES = "en_US.UTF-8",

LANG = "en_US.UTF-8"

are supported and installed on your system.

perl: warning: Falling back to the standard locale ("C").

locale: Cannot set LC_CTYPE to default locale: No such file or directory

locale: Cannot set LC_MESSAGES to default locale: No such file or directory

locale: Cannot set LC_ALL to default locale: No such file or directory

(Reading database ... 21173 files and directories currently installed.)

Removing bind9 ...

* Stopping domain name service... bind9 [ OK ]

Processing triggers for man-db ...

locale: Cannot set LC_CTYPE to default locale: No such file or directory

locale: Cannot set LC_MESSAGES to default locale: No such file or directory

locale: Cannot set LC_ALL to default locale: No such file or directory

How do I fix this error ?

Tags: server

User: hacktohell


Answer by otto-kekäläinen

First run locale to list what locales you are supposed to have:

Skip code block

$ locale

LANG=C

LANGUAGE=

LC_CTYPE=fi_FI.UTF-8

LC_NUMERIC="C"

LC_TIME="C"

LC_COLLATE=fi_FI.UTF-8

LC_MONETARY="C"

LC_MESSAGES=fi_FI.UTF-8

LC_PAPER="C"

LC_NAME="C"

LC_ADDRESS="C"

LC_TELEPHONE="C"

LC_MEASUREMENT="C"

LC_IDENTIFICATION="C"

LC_ALL=

The generate the missing locale and reconfigure locales to take notice:

$ sudo locale-gen fi_FI.UTF-8

Generating locales...

fi_FI.UTF-8... done

Generation complete.

$ sudo dpkg-reconfigure locales

Generating locales...

en_US.UTF-8... done

fi_FI.UTF-8... up-to-date

Generation complete.

Now you will not see any errors anymore!


Answer by marcin

Nothing suggested above worked in my case (Ubuntu Server 12.04LTS). What finally helped was putting to the file /etc/environment:

LC_ALL=en_US.UTF-8

LANG=en_US.UTF-8

For some reason it was missing. The outputs for locale and other commands appeared like the variables were properly defined. In other words don't take for granted all the basic stuff is declared where it should be declared.


Answer by rinzwind

They should disappear after issuing:

sudo locale-gen en_US en_US.UTF-8

dpkg-reconfigure locales


dpkg-reconfigure reconfigures packages after they have already been installed. Pass it the names of a package or packages to reconfigure. It will ask configuration questions, much like when the package was first installed.


Tags: server


Q: Chkconfig alternative for Ubuntu Server?


Q: What is LVM and what is it used for?


Q: How do I free up disk space?


Q: How do you restart Apache?


Q: Setting up a git server


Q: Debian Stable vs Ubuntu LTS for Server?


Q: Disable autostart for a service without uninstalling?


Q: How to add a PPA on a server?


Q: How do I set up an email server?


Q: How do I fix my locale issue?