Creating and opening Files Running a vi command without a file name will open a new file. Running a vi command with a existing file name will open that file for editing. For example, using vi test.txt will open a document called test.txt if it’s in the working directory. VI Modes Command mode treats input from the keyboard as vi commands. Command mode cannot be used for entering text. When a file is first opened, you start out in command mode and you will not see the words you are typing on the screen . To enter and edit text you have to switch to insert mode by pressing the…
-
-
Getting Started with tar
If we were in the directory Desktop and wanted to backup all the files to a tarball called backups.tar, we could issue this command: tar cvf backups.tar . The flags here:c creates an archive, v makes the process run verbose and f sets the file name. The . tells tar to back up the current working directory. Use pwd if you’re unsure what that is. As we didn’t tell tar where to put the file it will automagically put it in the working directory. By default tar is recursive although you can specify an n flag to alter that default behavior. Now, to display the contents of the tar file we just created,…
-
hostname
OK, so this one is pretty easy. You can use the hostname command to return back the name of your computer. There’s also a nifty little s flag to remove any domain naming from the return string.
-
Mac OS X Server: php.ini
A customer recently called asking us to expand the timeout variable for downloading files via PHP from their server. By default the php.ini file does not exist in Mac OS X Server. If you need to use php.ini to granularly configure the parameters for PHP then you should download it from php.net by downloading the source code for PHP for the version that comes up when you run php -v from your server. In the tarball there will be a file called php.ini-recommended. Then copy this file to /etc/php.ini and modify the appropriate settings: upload_max_filesize = whatever you want the new maximum to be posters.max_execution_time = 30 max_input_time = 60 post_max_size…
-
Sun Datacenter in a Can
http://www.sun.com/products/sunmd/s20/gallery/index.xml?t=1&p=1&s=1
-
Mac OS X: lsof
lsof is a command that can be used to list all the open files. You can use grep to narrow down the listing to only those that match a certain string.
-
Creating Directories Using -p with mkdir
I was helping someone out the other day and was VNC’d into their server watching them work. I asked them to make a directory about 5 levels deep into the file system. They proceeded to make each directory one by one using mkdir. When they were done, I actually removed them all so I could spend a second to show them how to do so much quicker… Let’s say the directory you need created is /tmp/usr/tmp. Rather than using 3 mkdir commands and cd’ing in between it would actually behoove one to go about using the -p option with the mkdir command. To make this directory structure you could actually…
-
Mac OS X: tail
I was on the phone with someone earlier today and they didn’t realize that they could dynamically watch new lines come into log files in Mac OS X. In order to do this you can use the tail command with the -f switch. So if you want to watch your system.log file and run some processes you think will cause errors you can use the following command: tail -f system.log When you’re done watching the log file use the Control-C keystroke to stop.
-
Writing Shell Scripts
There’s usually a few different steps in the learning process for writing shell scripts. The first is to figure out how to just do simple things, like write hello world to the screen. The second is to start using a series of commands. The third seems to be using variables. The fourth is to start using libraries to reuse your scripts. The next is to take variables to the next level, variabalizing everything. Where are you at with this?
-
Redirection
There are two types of redirection: arguments and operators. An argument is provided to a command in order for the command to use it as an input.