Change the Hostname on OS X

The PC or Mac machine you are using carries itself a sort of name or identifier, called the hostname. This name is especially important in networks, where you can identify a machine not only by its address, but also by that name.

You can either change the hostname on OS X by clicking through the settings, or by the nerdy way. Just open a new terminal window and type:

sudo scutil --set HostName [hostname]

A restart of the machine make sense afterwards to fully propagate the new name on the other network members.

Convert LaTeX Files to DVI and PDF Files on Linux and OS X

For all the LaTeX users out there: most of you use some kind of LaTeX editor. Usually you can trigger inside such editor the conversion of your LaTeX-based document to e.g. a PDF file.

In case you use the terminal, you can do this two-step conversion by the following commands:

latex [TeX file]
dvipdfmx [DVI file]

The first command will convert your LaTeX file into a DVI file. With the second command you transform the DVI file to the more popular PDF format.

Kill Processes on UNIX-based Operating Systems

Even though Linux, OS X or other UNIX-based operating systems are very reliable nowadays, sometimes applications can become non-responsive. On other cases, an application is running in the background without any GUI. The conservative approach to quit one application by clicking on the X button ist here not possible.

Thank god there is the terminal, where all the launched programs can be listed. A program or applications runs usually as one or more processes. A process is just a term to describe a currently executed program.

With ps aux one can list all started processes in the terminal. Since it is a usually a large list, it makes sense use grep for filtering it for a specific application.

ps aux | grep [application name] 

Finding the process entry of a an application always gives a unique and so called process ID. With the command

kill [process ID]

the application can be finally terminated.

Formatting a Medium on Windows via the Command Prompt

On UNIX-based OSes formatting a medium is usually done in the terminal. The good thing is that the required terminal commands are easily found on the web.

On Windows it is the other way around. Formatting is done in the OS’s graphical tools: in the explorer or the management window. A little less known is the formatting of a medium via the Command Prompt. Here’s how it’s done:

  • Open the Command Prompt as administrator by:
    • Pressing the START button
    • Typing cmd in the search box
    • Pressing CTRL + SHIFT + ENTER
  • In the Command Prompt type:
    • diskpart
    • list disk (remember the number of the medium you want to format)
    • select disk [number of device]
    • clean (optionally; cleans all existing partitions)
    • create partition primary (… and creates a new one)
    • select partition=1
    • active
    • format fs=fat32 quick (as an example, the new partition is formatted with the FAT32 filesystem)
    • assign
    • exit

Changing File Ownership

When UNIX was created back in the 70s, it was strictly developed as multi-user OS. For this reason, files on UNIX had an owner, so that only this owner and the all-mighty root could decide which read, wright and execution rights could be given to the other users on the same system.

Linux and OS X being both UNIX-based operating systems, share this feature. To change the ownership of file, the chown command is used.

chown [user] [file]

For assigning the file to your own username, one can use:

chown $(whoami) [file]