Journal bennett000's Journal: *NIX crash course
This is a crash course in *NIX CLI usage I just gave a friend.
*NIX Command Line in a nutshell, including stuff you already know, that I'm including for future copy/paste purposes. I'll try and keep it concise:
UNIX/Linux/GNU/BSD, and even Macs are all systems that share some common low-level-interface commonalities. This isn't to say they operate the same way, they just present the user with a somewhat consistent 'view' of how your computer's internals relate to each other. Given this consistent 'view' or abstraction applications like shells can operate consistently across the platforms. (Abstraction is critical to every level of elegant computing, but that's a whole other story)
Shells provide the user an interface to the computer. CLIs are a subset of shells, and provide a language oriented interface to the computer. GUIs of course are also a subset of shells, and provide an audio/visual interface to the computer. This discussion will of course be concerned with the CLI subset.
CLIs evolved out of Victorian era telegraphing principles, notably early stock tickers. Communications pushed these machines further, as code breaking machines started turning into computers during the early to mid twentieth century, the CLI was 'born' with the 1950s teletype machine. Teletypes evolved into terminals, through batch processes, and eventually UNIX. Despite the early eighties breakup of Ma Bell, UNIX / C, and its principles have continued to exercise a massive influence on computing.
Modern CLIs fall into four categories, Bourne Shell derivatives, C shell derivatives, Windows/DOS command prompt, and other. Bourne Shell descendants make up every single default Shell, on every open source operating system I've ever used. That's not to say there isn't merit to the C-Shell, Windows/DOS, and the others, but given their prevalence, we'll be discussing Bourne derivatives.
Before diving into the nuts and bolts of a Bourne style CLI, it's important to have an idea of how a typical *NIX system is laid out. Typical *NIX systems are made up of a file system that represents everything from a spreadsheet to a web-camera. Remote files can often be referenced straight from the CLI, just by providing a URI.
The most common root folders on a *NIX system:
Most *NIX systems have other folders too, but these are the most common. *NIX systems aspire to be highly organized, but it's not uncommon for them to become convoluted, like Windows can be.
In addition to this there are other common folders, but they're more dependent on which flavor of *NIX being used.
To navigate with the CLI, the two primary workhorses are:
ls (dir on windows)
cd
ls/dir list the contents of the directory/folder you happend to be in. cd changes the directory. cd
Most versions of ls will support -F. -F adds some visual cues to tell you what files do what. Fancier versions of ls include colourized output that also adds visual cues. -F is more universal. -F will add a * to the end of filenames that can be executed, add an @ to filenames that are links, add a / to filenames that are folders, and possibly more.
With cd/ls you can start finding commands to run. To figure out what a command does, the easiest thing to do is run the command 'man'. man xxxx brings up the manual page for xxxx, which on a good *NIX system will be enough to learn what to do. OpenBSD has the best man pages I've seen in a free OS.
The next most common commands are likely:
mount/umount
grep
find
shutdown
clear
vi
nano
cat
more/less
ps
top
kill
the piping operator '|'
the redirection operators >, >>,
That's pretty much all you need to know to do 80% of CLI stuff. Obviously there's a lot of command specific parameters, especially with more complex servers/daemons.
Here's a few more commands to get into trouble with:
su - trys to authenticate as a super user
sudo xxxxx - where xxx is any command, attempts to run said command as a super user
sed - a low level one pass editor, good for all sorts of weird nerdy things
ifconfig - show info about the network, or configure a network device
ssh - launch a secure shell, this command will let you log into a remote system and use a shell there. SSH supports X11 too, so it can be GUId.
scp - secure copy, copies files to/from systems using ssh
cp - copy files within your system 'cp -r' copies recursive
mv - move/rename files within your system
mkdir - make a folder
rmdir - remove a folder
rm - remove a file 'rm -r' recursively remove
rsync - low level copy 'just what needs updating' possibly one of the most handy programs ever conceived. extrmely useful, operates easily over SSH for secure remote updating/backup.
chown - change ownership of a file
chmod - change file permissions
ctrl-alt-F1-FX, sometimes just ctrl-F1-FX launch alternate terminals. In the context of *NIX GUIs F7 is often X11, or the windowing system, and F1-F5 are traditional non GUI terminals. This feature is less relevant now, as most nerds seem to use several of their preferred X-based applications. Most modern terminal apps support tabs etc, which is quite handy.
There's probably a lot I haven't mentioned, but I think this provides a good foundation for working with a *NIX command line.
*NIX crash course More Login
*NIX crash course
Slashdot Top Deals