Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
User Journal

Journal: *NIX crash course

Journal by bennett000

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: /boot /etc /usr /bin /var /tmp, /home /home/*user*/.xxx /mnt /dev

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. /boot stores all the stuff your computer needs to boot up. In DOS terms, this would be autoexec.bat, config.sys, msdos.sys, command.com... In *NIX terms, it often has the kernel, and boot-loader /etc stores all of the system, and service/server/daemon configuration files. /etc usually is divided into sub folders that pertain to the complexities of web server configs, boot scripts, cron (scheduler) tasks, remote shell (SSH) configs, proxy settings, etc! /usr contains the system's primary application data. /usr usually has a /usr/local sub folder for user specific applications. /usr, and /usr/local usual contain a centralized repository of installed applications, their libraries, and their source /bin contains executables. bin directories appear as subsets of other directories. Notably /usr/bin, /usr/local/bin, and so on. Binaries contained in /bin folders are almost exclusively executables. /bin is the root binary directory and contains all of the systems most key executables. The other bin directories, contain /bin files specific to their location. Installed applications typically have their binaries in /usr/bin. *NIX systems also often include a /sbin directory for system binaries, or scripts, that's essential, but not as essential as /bin /var contains variable files, logs, printer spools, web caches, e-mail caches, information on currently running processes, webserver data, and more. /tmp is for temporary data /home contains all the user space, it's /Users on Macs /home/*. files/directories beginning with a '.' usually represent local user configuration files/directories, and override system defaults. /mnt is an empty directory used for temporary mounts. /dev is one of the most important root folders in that it contains access to the computer's devices. /dev/sda1 for example is the path to the first partition of a SCSI/SATA drive on a typical Linux system. BSDs might be a little different, and might be /dev/wd0s1. BSDs tend to use device names/brands to represent their /dev nodes, where as Linux has evolved to what they call udev, and it provides unique device IDs that are dependent upon the hardware, and UIDs

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 .. goes up a folder.

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 >, >>, /mnt/secret_key.rsa will dump the contents of the file id_public to a new file in the mnt directory. cat /mnt/id_cole.pub >> /home/cole/.ssh/authorized keys would append the contents of the file id_cole.pub to the authorized_keys file in the user cole's home folder under ssh's '.ssh' config folder.

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.

User Journal

Journal: Apple Philanthropy Rebuttal

Journal by bennett000

Over the past week-end, the Canadian press published a story about Apple having more money than the US treasury. The link showed up in my social networking stream. I just had to say something about Apple not having a philanthropy program, despite the cash. I was quickly rebutted, by another user who claimed apple had 'countless' programs to help underprivileged orphans. Some companies do keep their charitable sides on the down low, but with a company as large, and as wealthy as apple, and with allegedly "countless" charities, one would expect to quickly be able to find something on Google, I have not.

Here was my rebuttal:

I won't deny the existance of the programs Eric has mentioned, but I can't find any information about them what so ever (note* I'm on a rural connection right now, and it's slow)

Googling "Apple" with various combinations of: philanthropy, charity, donate, donations, under privileged, etc yields only polarized links about how apple does not give to charity.

In fact this link includes an alleged letter from Apple (2007) that effectively says they don't do charity

http://www.cultofmac.com/does-steve-jobs-care-about-global-poverty

I did find another link that claims apple gave $100,000 fight California's prop 8, and support gay marriage:
http://www.sfgate.com/cgi-bin/blogs/techchron/detail?entry_id=31899

I've also found links about people using iDevices to help their efforts in developing countries, but nothing about direct Apple contributions, with the exception of the "Red" campaign from 2002:

http://news.cnet.com/Red-iPod-supports-AIDS-charity/2100-1041_3-6125608.html

Now the thing about Red is, as much as it's charitable, only 50% of the sales value of a product makes its way to the Red program, plus Apple ships more units... Apple products are designed to force their users to purchase content and applications from Apple, who then take a 30% cut (even on the content) so I see the Apple's involvement in the Red program more as a smart business move than a noble action...

Also $75,000,000,000 is a lot of money. I mentioned 100k earlier... lets put this number into perspective. 100k is to $75B as one penny ($0.01) is to $750.... so what exactly does a company like apple do with $75B?

Well they're likely using it to secure a monopsony on the tech trade.
http://tech.fortune.cnn.com/2011/07/05/how-apple-became-a-monopsonist/

Basically Apple uses their cash reserves to fund the building of city sized factories in China... which of course leads to the topic of Foxconn suicides

http://www.wired.com/magazine/2011/02/ff_joelinchina/

http://www.bbc.co.uk/news/10182824

So does Apple really give back in big ways? I haven't found anything to support this yet, I'd be happy to see some information on the subject, and I'd be happy to contrast it with all the HARM Apple does....

We haven't even touched the ecological ramifications of Apple's business practices, and Apple's disdain for industry standardization...

Crime

Journal: Online crime, and online "crime"

Journal by bennett000

After two months of what can only be described as aggressive e-vandalism, serious arrests are finally being made by various authorities. Opinions on the subject are intense and polarized, this journal entry is not concerned with that debate; the concern is the definitively calculable online crime that is also going on, and how it is being pursued/reported by the authorities/press.

Online crime seems to have fallen in quantity but also increased in quality. In the late nineteen nineties it used to be that malware just slowed your computer down. Now it secretly owns and defends your computer, and in the case of stuxnet, controls nuclear reactors.

What this country needs is a good five dollar plasma weapon.

Working...