This tutorial is intended for to familiarise users and system administrators who are familiar with Microsoft Windows environment with the Linux command line. Linux has a powerful graphical user interface similar to Windows and Macintosh, but much of the power of Linux is only unleashed at the command line. Almost everything is equally applicable to UNIX.
Install PuTTY, choosing "Windows installer for everything except PuTTYtel".
On some versions of Linux you will get better output if you choose Window -> Translation -> Remote character set: UTF-8, and Use Unicode line drawing code points. Now save as Default Settings under Session.
Install CygWing/X (be sure to include X11 in installation) or XMing.
You can also install Linux on a USB stick, and boot from the USB stick instead of from Windows on your C:. You can still access files from your C:, and you can even install Linux on your C: so that you are given a choice between starting Windows and Linux each time you boot. There are many variants or "distributions" of Linux, for desktop use I favor Ubuntu since it comes with the software to play MPEGs and Flash player sites easily installable from the Ubuntu Software Center.
ssh -Y user@host
". To logout, Ctrl-D Ctrl-C. If you close the xterm window, start it again with Start -> All Programs -> Cygwin/X -> xterm.
ssh -Y user@host
". To logout, Ctrl-D Ctrl-C.
You should be at a command line prompt similar to [user@yourhost ~]$ . The ~ is a short cut representing your home directory.
$ pwd
/home/user
On some systems the actual location of your home directory will be different, e.g. on large systems it may be sorted into subdirectories by initial letter /home/u/user. No matter what, ~ always represents your home directory.
$ ls /home
user1 user2 user3
List in long format, with owners and date
$ ls -l /home
drwx------. 4 user1 user1 4096 Mar 11 18:37 user1 drwx------. 4 user2 user2 4096 Mar 11 18:37 user2 drwx------. 4 user2 user2 4096 Mar 11 18:37 user3
Files that start with a "." are hidden by default in Linux. List all files in current working directory, in long format, including hidden files:
$ ls -al
total 6
drwx------. 5 wrcourt wrcourt 4096 Mar 24 13:07 .
drwxr-xr-x. 6 root root 4096 Mar 20 14:27 ..
-rw-------. 1 wrcourt wrcourt 688 Mar 20 19:36 .bash_history
-rw-r--r--. 1 wrcourt wrcourt 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 wrcourt wrcourt 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 wrcourt wrcourt 124 Jul 18 2013 .bashrc
The entry "." is a system defined entry that represents the current directory. The entry .. represents the directory above the current one.
Get more information about all the options for the ls command:
Use <space> to advance through help text, <q> to quit.
$ $ Press <Up-Arrow> until $ $ $ The classic text editor on Linux is vi. It is extremely powerful, allowing all sorts of wild cards (regular expressions). It does require a few hours to learn the basics. The variant on Linux is actually Vim, an improved version of the original vi.
$ The <Insert>, <Delete> and arrow keys should all work, even though vi tutorials generally assume that they don't. Use <Esc> to get out of insert mode. There are many tutorials for vi. I strongly encourage you to spend a while doing one.
If you are using Cygwin/X or Linux from a USB stick:
$ This will not work with PuTTY, since it is purely an SSH (command line) client, not an X server.
If you truly have no time to do a vi tutorial, nano may be installed.
$ Menu driven, Ctrl-X to exit.
Type out file with no pauses:
$ Type out file with pauses:
$ Use <Space> to move forward through file, Ctrl-B to move back, q to quit, / to search for specific text, h for help on more keys.
Type out the beginning of a file:
$ Type out the end of a file:
$ Search for all lines in file /etc/services matching a string:
$ $ The | between two commands "pipes" the output of one command in as the input of another command. Unix has a powerful collection of text processing tools - try $ If you have been following this tutorial closely, you are in the directory foo. Change back to the home directory first:
$ and remove the directory:
$ Linux, like its predecessor UNIX &tm;, is fundamentally multi-user and multi-tasking - Unix was from inception, in the days before GUIs.
Who is currently logged on:
$ What processes are running:
$ What processes are taking up the most CPU time:
$
UNIX For Dummies,
John R. Levine and Margaret Levine Young
The Unix Programming Environment, by Brian W. Kernighan and Rob Pike
Search Amazon.com:
E-mail me at Wrolf Courtney <wrolf@wrolf.net> with any comments or updates.
man ls
Make a new directory
mkdir foo
Change directory
cd foo
Recall recent commands
ls -al
command appears, press <Enter>.
ls -al
total 2
drwxrwxr-x. 2 user user 4096 Mar 24 13:20 .
drwx------. 6 user user 4096 Mar 24 13:20 ..
Copy a file from another directory into the current directory
cp /etc/hosts .
Rename a file
mv hosts copy
Edit a text file
Edit a file with vi
vi copy
ZZ
to exit.
GUI text editor
gedit copy&
Menu driven text editor
nano copy
Viewing text files
cat copy
less copy
head /etc/services
tail /etc/services
grep nfs /etc/services
grep udp /etc/services|less
man grep
, man sort
, man awk
, man find
, man xargs
, and man perl
just to get started.
Remove file
rm copy
Remove a directory
cd
rmdir foo
Multi-user, multi-tasking
who
ps -ef|less
top
1
to show separate state of CPUs on multi-CPU/multi-core machines, h
for help, On
to sort by memory usage.
Further Reading
Kudos & Brickbats