Quantcast
Channel: Linux and Mac Hacks
Browsing latest articles
Browse All 39 View Live

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

Image may be NSFW.
Clik here to view.

SSL: View certificate info

I frequently need to do this to verify when a cert expires or who issued it. You can get all the information associated with a cert by typing:openssl x509 -text -in cert.pem

View Article

Image may be NSFW.
Clik here to view.

Using screen

Here is a quick how-to for the screen utility found on *nix systems:1. To start a new screen session type 'screen'2. Once inside to open a new window 'ctrl-a c' (create)3. To cycle through the windows...

View Article


Image may be NSFW.
Clik here to view.

How to see what a program is calling or files it is using?

Sometimes it is useful to see what system calls a compiled program is making. strace is a great utility to use for this, here is an example:strace -f -s 500 -o /tmp/strace.output dig somedomain.comThe...

View Article


Image may be NSFW.
Clik here to view.

Tunnel X Windows over SSH from a Linux Server to Mac OS X Mountain Lion

First lets setup the Linux Server. You need to add the following two directives to the sshd config, on Ubuntu it is found in /etc/ssh/sshd_config (look at the file first, it might already be in...

View Article

How to run processes concurrently or simultaneously on Linux aka Instant DDOS

There may be a time that you want to run a script like "dothis.sh" multiple times concurrently (simultaneously) - the following script runs 5 concurrent instances of...

View Article

Mac OSX - Use your old Airport, Airport Extreme or Time Capsule to extend...

If you have an old Airport, Airport Extreme or Time Capsule and want to use it to extend a wireless network you already have setup (with some other brand wireless router), then you can follow these...

View Article

How to run Windows programs (like Internet Explorer) on a Mac

Here is a nice free way to run Windows on a Mac without having to buy VMWare or use WINE.1. First download VirtualBox from Oracle:https://www.virtualbox.org/2. Then open a terminal...

View Article


CentOS: Add another ip to interface eth0

To add another IP address to interface eth0, create a file /etc/sysconfig/network-scripts/ifcfg-eth0:1and add the following:DEVICE=eth0:1...

View Article

Postfix: Send from a particular IP address

To make Postfix send from a specified IP address, first make sure the IP address is present on the server and routable (i.e. has right subnet, gateway, and is enabled). Then add the following to...

View Article


Use grep and regular expressions to find a URL

I spent a lot of time searching through a number of different regular expressions to find a URL in a body of text and finally ended up with this one - make sure you replace somefile.txt with the file...

View Article

Emacs: Permanently stop creating backup files and auto-save

In case you ever wanted to permanently stop creating backup emacs files (the ones with ~ at the end of the filename) add the following to your .emacs file:(setq backup-inhibited t)and/or disable the...

View Article


Find the current directory in a bash script

This is a useful one line to find the current directory in a bash script:DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")"&& pwd )"

View Article

Change gpg key passphrase on Mac OS X

How to change your gpg (private) key passphrase0. If you dont have gpg installed, you can get GPGTools a nifty application suite to manipulate your keys and much more from http://gpgtools.org1. First...

View Article

sshd error: buffer_get_ret: trying to get more bytes 4 than in buffer 0

You try to ssh to a server and the connection is immediately closed.In the logs you see this strange and cryptic error:Oct 29 10:24:24 sbweb03 sshd[30714]: error: buffer_get_ret: trying to get more...

View Article

MySQL error: Got error 28 from storage engine

If you receive this error "Got error 28 from storage engine" from MySQL, check your disk space on the server. Typically the error is due to a full disk. 

View Article


Enable sar on Ubuntu

System Activity Report (sar) is a utility that lets you measure performance on *nix machines.sar comes in the sysstat package and includes: - sar: collects and reports system activity information;-...

View Article


check the number of command line arguments in a bash script

You can add the following to the beginning of your bash script to check for the number of arguments and exit if you don't have the required number, simply modify the EXPECTED_ARGS to the desired number...

View Article

Image may be NSFW.
Clik here to view.

Using Chrome with tor on Mac OSX Mavericks

After spending some time using the Tor Bundle that is distributed for Mac OSX, I decided that Firefox just wasn't for me. I prefer Chrome, and was able to get it working with tor on a Mac running...

View Article

Macbook Air/Pro Thunderbolt Port not working

In case you are using an external monitor and you get a no signal message from your computer. You can reset the ports via the following method:1. Shutdown the computer2. Hold down the...

View Article

Browsing latest articles
Browse All 39 View Live




Latest Images