Friday, March 18, 2011

SSH and Linux


SSH and Linux

Meant to put this up yesterday, but better late than never.

I guess this is my first technical post about programming. Well, not really programming… whatever.

My first experience with Linux went something like this: install whatever the popular distro of the day was, get any additional hardware working right, play around with it for one or two day, then format and install Windows. Because OS that you use really isn’t all that important as long as your familiar with it.

When I went off to college, I got much more rigorous training in Linux (and all Unix based systems) trying to compile code on the lab machines through CLI.  Was like a whole different experience. And I am going to impart some of the wisdom I gained to you my loyal reader (lucky you!).

Something important about Linux: Everything in Linux is a file. Also, see the picture for the breakdown of the directories.
If the place you’re working at supports SSH, your weapons of choice will be PuTTY (for general CLI) and Webdrive (for SFTP file transfer). PuTTY is free but Webdrive will cost you money. There are free software that does Webdrive’s job, but in my opinion, not as well. PuTTY can also be used for tunneling, which can be useful in … circumstances.
ls = list files in a in a directory. Use “ls –a” for detailed info. In case you don’t know –a is an argument to the program ls, you can pass multiple augments to a program as such “ls –a –rf” ect.
pwd = gives your current directory
cd = change your current directory. “cd ..” will move you to your parent directory as “..” represents to the parent directory
. = at is a way to denote the current directory. Say you need your current directory to run your program “a.out”, you’re going to want to say “./a.out
mkdir = create a directory. To create a directory called foo say “mkdir foo”. You can also use –m to specify a mode.
rm = remove a file. You can’t use rm to remove a directory unless you use “rm -rf” to recursively go into each folder, remove it’s condense and remove the folder.
more = print out the contense of a file
emacs = emacs is a popular text editor. Hit Ctrl-X and Ctrl-C to close emacs.
top = displays all the processes running. Like a task manager but CLI.
gcc = C++ comiler. –o tell it what to name the compiled file. –Wall gives you more warnings, but those are just warnings, it won’t break your program. –pedantic –ansi holds the program to stricter standards. –g compiles for debugging with gdb (I never used gdb, though it has some interesting features, I stuck to printf’s and getf’s to debug when I couldn’t use a proper IDE).  So the whole thing would look like “gcc-o hello hello.c –Wall –pedantic –ansi –g
tar = –cvf creates the archive as such: “tar -cvf file.tar file1 file2 file3” tars file1, file2, and file3 into file.tar.  –xvf untars a tar file.
scp and sftp – in certain cases, you won’t be able to use Webdrive or your SFTP client of choice. Use scp to send files, sftp to get.

No comments:

Post a Comment