newbie

How to keep the existing file attributes (owner, timestamp, etc) when copying files or directories

command line

When copying files and especially directories, sometimes you want to keep the existing file attributes. For example, you may likely want to keep the same owner, group, timestamp, etc. You can keep the attributes by using the preserve argument. preserve=all will keep everything: You can use the -p version of preserve to keep the default [...]

Read the full article →

How to Check the Ubuntu Version.

command line

How do you know which version of Ubuntu you are running? This will return something like this:

Read the full article →

Configuring Log Rotation of Apache2 and Other Logs

apache

I went to check out my apache2 logs and I noticed that they were being automatically rotated (access.log, access.log.1, etc.) and compressed with gzip (access.log.2.gz, etc.). This seems to be the default Ubuntu configuration. I wanted to make find out more, and I found this helpful article about Ubuntu logs, including Apache2 Log info and [...]

Read the full article →

How to rename a file or directory

command line

There is no rename function in Ubuntu Linux. Instead, you simply move the file, giving it a new name. If you don’t actually mv it to another directory, then you have effectively renamed it: If you are trying to rename a directory, you need to use the -r recursive flag:

Read the full article →

How to move or copy a directory

command line

I was trying to copy a directory, and I kept getting a cryptic error: cp: omitting directory `/var/log’ The copy (cp) command only works for files. To copy a directory, you need to use the -r recursive flag: In this case, I was trying to copy the log directory to make a quick and dirty [...]

Read the full article →

How to change your password from the command line

command line

To change your own password from the command line: To change the password for another user, you must use sudo:

Read the full article →

How to easily view the end of a log file

newbie

Ubuntu/Linux log files can be quite long with many entries, but usually you only care about the end. So, how can you quickly view the last few entries in a log file? Use the tail command: To watch the latest output as it happens, use the -f flag When you are done viewing, use CTRL-c [...]

Read the full article →

How to view the current time from the command line

command line

To see the current time from the Ubuntu or Linux command line: date which will give you: Fri May 30 15:53:21 EDT 2008 To see how to include and format dates and times in your shell scripts, see this post: http://www.lifeonubuntu.com/2008/05/how-to-format-dates-in-shell-scripts.html

Read the full article →

How do I know which kernel I am using?

newbie

How do you know which linux kernel you are using? uname -kFind out other system info withuname -a

Read the full article →

How to prevent server (daemons) from starting during apt-get install

newbie

Some times you may not want a server or daemon to start as part of the postinstall scrip when installing with apt-get or dpkg. To prevent servers from starting, do the following: # Prevent launch of servers during apt-get install mkdir -p /usr/sbin/ cat < /usr/sbin/policy-rc.d #!/bin/sh exit 101 EOF chmod 755 /usr/sbin/policy-rc.d When you [...]

Read the full article →