CLUELESS at the Prompt
If you are familiar with that other windowing system, you may be aware of the concept of multitasking. Using a single computer to do several applications at once is a highly desirable trait for an operating system (OS).
It's fairly obvious how to accomplish this in a windowing environment, but not so obvious at the shell prompt. Here are some of the details.
When you start a program at the shell prompt, you can stop it by typing:
which returns you to the shell prompt. Then type:
bgand the program or job is restarted in the (b)ack(g)round. A job can also be put in the background from the beginning by typing an ampersand (&) at the end of the command, e.g., make filename&. Running your job in the background allows you to run another job at the same time without changing to a different virtual console (VC). The job can be brought back to the (f)ore(g)round by typing: fg, if its the only background job, or fg jobno, if there is more than one.
You can change to a different VC by using the Alt-F2 (through F6) command. Each one of these can also be used in the manner that I have described, to the extent that you can easily run out of resources in a fit of deep-hack-mode euphoria, if you aren't careful. If you get really exuberant, you could even forget which jobs you have running. Relax, you can “remember” them by typing:
This command lists all jobs running in the background, much like the ps command lists all processes that are currently using up your precious memory and CPU.
When you boot up Linux, your file system or rather your hard drive must be mounted, so that the file system can be read and acted on. Your floppy drive, tape backup or CD-ROM cannot be automatically mounted, so you may need the mount utility. For example:
mount -t ext2 /dev/fd0 /mnt
mount -t msdos /dev/fd0 /mntmounts your floppy drive (called a: by DOS) to a directory called /mnt from which you can access files on floppy disks. In the first example, the /mnt directory can be read into the ext2 file system, while the second reads floppies written in MS-DOS format. To read the contents of the floppy drive, which is now /mnt you can type:
cd /mntthen, ls or less filename.
In a similar manner, you can mount your other floppy drives, tape drives, CD-ROMs or other read/write devices. These devices can be unmounted using the command:
or umount /dev/whateveryoumounted<\n>.
Here are a few tips that can make your Linux life a little easier.
Suppose you make a typo in your command that you don't catch until after you press enter. If the environment variable FCEDIT is set to emacs (default for the bash shell), you can correct it without retyping the whole command by tapping the up arrow key to bring back the previous command for editing with emacs. In fact, you can use the up arrow key to go up through the history file and the down arrow to come back down if you go too far. If FCEDIT is set to vi (default for the ksh shell), press ESC (escape key) then use k to go up the history file and j to go down, and of course, use vi to edit the faulty command.
To change back to a directory you have just left or to scan subdirectories, use:
in the following manner. Change from your /home directory to the main trunk directory:
cd /then, to look at the top level of each directory, for instance, type:
cd usrthen ls. If you didn't find what you were looking for, type:
and you will find yourself at the trunk / again. Unfortunately, you can only go one layer deep, but it is still useful when you install a source package and want to check out the contents of each of the subdirectories.
Sometimes, at least at first, you may not know how to stop a program or process that's running, but you are unwilling to let it slowly eat up your memory or CPU overhead. To get rid of it, first find its pid (process identification) number by typing:
to get a list of all running processes. Make note of the pid number and type:
killThere is another way to do this that is actually easier. Browse through the LSM (Linux Software Map) for a utility, actually a nicety, called die-1.1. You can unpack this utility into a directory or use installpkg dopkg or whatever your single package installation utility is. Then look for the /die-1.1 and cd to it. This directory contains a couple of files: a source file called die11.c and a documentation file called die.doc.
Assuming that you have installed the GCC compiler, just type:
gcc -o die die11.c
hit ENTER, and presto, you've compiled the die utility. Just mv it to a directory in your path, and if you like, mv the die .doc to /usr/doc or somewhere it can be with other help text friends (but not man pages, they'll pick on it unmercifully). Now, next time you're in a quandary about how to gun down a process just type:
dieand it will do the deed without having to look up the pid number. To find out more about die just type:
diewith no argument and it will give you a summary of the commands you can try the up arrow keys on.
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Keeping track of IP address
50 min 47 sec ago
- Roll your own dynamic dns
6 hours 4 min ago
- Please correct the URL for Salt Stack's web site
9 hours 15 min ago
- Android is Linux -- why no better inter-operation
11 hours 31 min ago
- Connecting Android device to desktop Linux via USB
11 hours 59 min ago
- Find new cell phone and tablet pc
12 hours 57 min ago
14 hours 26 min ago
- Automatically updating Guest Additions
15 hours 35 min ago
- I like your topic on android
16 hours 21 min ago
- This is the easiest tutorial
22 hours 57 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?