Common commands

Several articles back I asked the question “Command line or GUI?” While most are familiar with the GUI, many may not know where to start with the command line. What follows are some of the commands I find not only useful, but that I use almost daily. By the way, to get to a command line on a Windows system, go to Start -> Run-> and type cmd, if you do not have PowerShell, I recommend you get a copy, it is free. On *nix find a shell icon or something that indicates a console. There are a variety of shells out there and depending on the age of the equipment, you may encounter different shell versions. Also, there is no guarantee that the command you need is actually loaded on the system. Today many apparently dedicated devices are actually Linux or Windows boxes that run a specific task. Many of the ‘optional’ parts of the operation system are left out so that what remains can be stored on a small solid-state drive. Also, be aware that most *nix systems are case-sensitive, whereas Windows is usually not.

To get a list of the current NICs and their IP addresses use ipconfig (DOS) or ifconfig (*nix). I end up using this every time I check into a new hotel. My company laptop has the company intranet as its home page, and I normally have to find the gateway and type the gateway’s address into the browser’s address bar to get to the hotel’s sign on page.

telnet or ssh can be used to log into a remote machine if the ports are open. Telnet is fairly simple, type telnet and the ip address or hostname: telnet 192.168.1.11. ssh (secure shell) typically requires a username along with the hostname or ip address:
ssh root@192.168.1.11. Many systems require you to log in as a regular user, then switch to root once you have logged in. That is accomplished with the su (switch user) command. The root user is assumed, or you can switch to a different user (steve) by typing su steve. You will need to provide the password for whatever user you are logging in as or switching to.

ftp or scp can be used to copy files from one machine to another. ftp and scp clients are available for the GUI, but sometime all you need is a simple file copy, and both can be used (ftp in less secure enviroments, scp in secure areas). Command line ftp, like telnet is invoked with ftp and either the ip address or hostname. Scp is a little harder to get used to, but can typically be used at either end (source or destination) to move files either to or from another machine. It is typically called from the destination side with scp user@ip_address:remote_filename local_filename or
scp root@192.168.1.11:config.txt config.txt

In the GUI, folders are used to represent the directory tree. Within the CLI, use cd to change directories. The root, or top level directory is represented with a slash (/) in *nix and a backslash (\) in Windows. To go up one directory, use two periods (..). A single period represents the current directory. The users home directory is represented by the tilde (~). To switch to your home directory: cd ~, to switch to the root cd / or cd \ depending on the system. Most systems also have an autocomplete that will cycle through the available directories if you press the TAB key after typing cd. Windows directories may now contain spaces, and you may need to wrap the line in single quotes: cd ‘Documents and Settings’.

Often I am in a new system and not really sure what I am looking for or where I will find it. The find command is extremely helpful. The following command will search the entire system starting at the root for any file with the .log extension: find / -name *.log Be aware that unless you are logged in as root, (the super user on a *nix system), you may not have access to all directories on a system.

> and >> allow you to take the output of a command to a new file (>) or append an existing file (>>). If you were looking for something using find and found hundreds of matches, it could be difficult to locate what you want. Using find / -name *.log > logfiles.txt will produce a text file with the results that can be viewed/searched in Notepad or another text viewer.

These are but a few examples. I have found the more I use the command line, the better I get at doing complex tasks in it. Not surprisingly, there are many tasks that are straightforward at the command line but are complex or nearly impossible in the GUI without an application or special software.

About SJE

Owner/editor of BroadcastBuyersGuide.com
This entry was posted in Basics, General and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>