Quantcast
Channel: Linux and Mac Hacks
Browsing all 39 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Mac OSX: Set a global environment variable

Variable Name: SOME_NAMEVariable Value: /etc/somefileTo make the global variable be created every time OS X boots:echo setenv SOME_NAME /etc/somevalue > /etc/launchd.confTo make the global variable...

View Article



Image may be NSFW.
Clik here to view.

Mac OSX: Restart Apache

To restart Apache:  sudo /usr/sbin/apachectl restart

View Article

Image may be NSFW.
Clik here to view.

Ubuntu Linux: Set a global variable

To set a global variable in Ubuntu Linux that is available even after a reboot, you need to edit /etc/environment and add:VARIABLE=VALUEfor example, you can addEDITOR=/usr/bin/emacs 

View Article

Image may be NSFW.
Clik here to view.

PHP: Which php.ini is being used

To find out which php.ini is being used by your system try:php -i "phpinfo();" | grep php.ini

View Article

Image may be NSFW.
Clik here to view.

Emacs: Set default tab size

You can set the default tab size in Emacs by adding the following line to your .emacs, replace # with the number of spaces:(setq default-tab-width #)

View Article


Image may be NSFW.
Clik here to view.

Mac OSX, Linux: Get SVN to Ignore a file

To get SVN to ignore a file, i.e. not push it back to the repository even if it changed, you need to do the following:1. Set up your editor, in my case I use emacs, in your ~/.bashrc fileexport...

View Article

Image may be NSFW.
Clik here to view.

Linux: Send an attachment via the command line

You will need mutt to do this. You can install mutt via your package manager, in Ubuntu you can use:apt-get install mutt To send the attachment you use:mutt -s "The subject of this message" -a...

View Article

Image may be NSFW.
Clik here to view.

Linux & Mac: Remove files older than a certain date

You can use the following code to remove files older than a certain date:find /path/to/files/* -mtime +numdays -exec rm {} \;Replace /path/to/files with the directory you want to scan, and numdays with...

View Article


Image may be NSFW.
Clik here to view.

Mac OSX & Linux: How to list all DNS records for a domain

To list all the DNS resource records for a domain, you can use nslookup:nslookup -q=any domain.comReplace domain.com with the name of the domain you want to lookup.

View Article


Image may be NSFW.
Clik here to view.

Linux: Dovecot "save failed waiting for lock error"

If you get the following error:save failed to INBOX: Timeout while waiting for lockThis indicates that Dovecot's locking mechanism somehow got corrupted. To fix you can try the following steps: Stop...

View Article

Image may be NSFW.
Clik here to view.

Linux & Mac OSX: Remove blank lines from a file with awk

Here is nice awk one liner to remove blank lines from a file, just replace FILENAME with the file you want the blank lines removed from: awk '/./' FILENAMEHere is a sed one liner to remove blank lines...

View Article

Image may be NSFW.
Clik here to view.

Emacs: Backup Files

Do you find those backup files (somefile~) annoying? If so you can do two things:1. Store them all in a directorymkdir ~/backupAnd add the following to your .emacs:(setq backup-directory-alist `(("." ....

View Article

Image may be NSFW.
Clik here to view.

Mutt: Get mutt to look at your Maildir folders for mail

To get mutt to look at your maildir folders for mail you need two things:1. You need to set your MAIL environment variable in ~/.bashrcMAIL=/home/YOUR_USERNAME/Maildir2. You need to tell mutt about...

View Article


Image may be NSFW.
Clik here to view.

Mac OSX - Starting MySQL

To start MySQL on a Mac OS X machine you can type: sudo /Library/StartupItems/MySQLCOM/MySQLCOM start To stop MySQL on a Mac OSX machine, you can type: sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

View Article

Image may be NSFW.
Clik here to view.

Mac OSX - Set PATH variable

If you want to edit the PATH variable in Mac OSX, you can edit the /etc/paths file and add your entry. The default version looks like this:/usr/bin/bin/usr/sbin/sbin/usr/local/bin

View Article


Image may be NSFW.
Clik here to view.

Mac OSX - View Apache Errors

To view Apache errors, you have to look at the error log file called error_log. It is either in /var/log/httpd, or /var/log/apache2 depending on your Apache setup. You can see the most recent errors by...

View Article

Image may be NSFW.
Clik here to view.

Find modules loaded in iptables

To find out what modules are loaded in iptables try:cat /proc/net/ip_tables_matches

View Article


Image may be NSFW.
Clik here to view.

iptables Port Forwarding

If you need to forward one port to another you can type:iptables -t nat -A PREROUTING -i eth0 -p udp --dport SOURCEPORT -j REDIRECT --to-port DESTPORTSo if you wanted to route all traffic from port...

View Article

Image may be NSFW.
Clik here to view.

Blocking domains with BInd 9 like WebEx

You can block domains with bind 9 by first creating a dummy zone file called "poison" that has no records (copy the following file exactly):@ IN SOA ( ns1.domain.com. hostmaster.domain.com.           1...

View Article

Image may be NSFW.
Clik here to view.

Ubuntu, CentOS ssh hangs when you try to log in

You may encounter a server where ssh hangs when you try to login. Sometimes this error is due to a missing DNS record. You can fix this by editing your /etc/ssh/sshd_config file on the server to have...

View Article
Browsing all 39 articles
Browse latest View live




Latest Images