Keep up with VYL's Updates

8.07.2007

Linux Beginning Notes Compilation

In learning more about the linux kernal, platform, and OS, I had countless “key clarification” that, frankly, turned on the “light bulb” and really helped me understand what the hell is going on the linux world. This includes some of those essentials and a few not-so-essential-but-very-cool findings, as well.

Linux Installing File Formats (most to least complicated to install)

1. Source code (needs compiling and file placement, no wizard)
2. Binary (needs file placement, no wizard)
3. Package (. deb, .rpm automatically installs pre-compiled files into necessary folders, no wizard)
4. SE binary (automatically installs pre-compiled files into necessary folders, wizard)

Software Installation Dependency

Windows and macs provide huge clunky install files that already have all the system software code already installed in it. Linux files don't come with dependcy files, so to uninstall or install a program, you may need to respectively install or install dependency files. Yo u experiene dependency hell, when a package needs dependency files, which, themselves, need depency files!

Mounting Files -- Basics

Linux is so cool because you can add any harddrive and make it “normal architecture” that automatically mounts by adding to the /etc/fstab file, creating a directory for it under /media/ folder. Note: remarkable how like this is with Big Brother updates. Everything must be updated and cross-referenced if a “BB surplus reference was changed for example”. To add a constant external drive you have to change /etc/fstab, /media/ references to it! Then it shows up in Places.

Also, realized that me criticizing with evidence why some advice is wrong is very similar to showing command line errors in terminal! It's not insulting; quite informative and helpful! A person who looks at it as insults shouldn't really be using it!

Linux OS

Linux just refers to the kernel; the sensitive part of the OS that does everything. GNU provides the shell, the libraries, and the components that all a user to use the linux kernel. The shell prevents bad commands from destroying the kernel, so the shell is a necessary buffer. GNOME is a GUI shell, but typically the terminal is what is referred to as “shell”. GNU/Linux then is the whole OS – shell, libraries, AND kernel.

Shell Commands

Whenever you type a command in the shell, it is really running just a small little program (ls, cd, totem – all programs). The terminal knows where to find these programs by looking in specific folders. echo $PATH lists these folders. For me, they're /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games , seperated by a colon. If the program is found in one of those folders just typing the command will launch it, otherwise you'll have to type the direct location of the command (or add it's folder to the PATH) or if the program is in the current folder, just precede it with “./” (./ means execute it right here). So way's to run programs:

l ./ -- if program is in current folder

l “program name” if program is in PATH variable

l “location/of/program” -- exact location of program name.

Extensibility Flexibility

Linux epitomizes life because you can change and do ANYTHING to the OS – if you want a folder to pop out a certain way, a menu to be added to a menu, anything, you can change it in linux!

System Variables

These tell, among other things, where commands are located for them to be executed from the command-line prompt. You can see the code for system variables with the “set” command.

Aliases

AWESOME trick. To permanently create an alias (another shortcut for a command or sequence of commands) just append to the end of the .bashrc file (the resource file for all bash shell work terminals) the following line

alias ='linux command'

so for example to create a shortcut for sudo apt-get install, an enormously painful experience to keep typing, just add this line of code to your .bashrc file:

alias sagi='sudo apt-get install'

Awesome! (Note: you must not have any spaces between the “=” sign (That threw me off at first). Just restart the terminal window or reboot and tot download a program just type:

sago program_name

List Command – ls

Okay ls is pretty straight-forward and basic. The fun stuff happens with options.

-h – (combined with -l) produces human-readable formats, meaning instead of byte sizes, kilobyte and megabyte sizes

-l (long format, including permissions and author and modified. tons of information

-a (all files, even invisible with “.” before the name.

Copy and Move Commands –cp mv

Okay Copy, cp is again basic. It adds a new file or directory to the new path name.

cp file1 /home/kooz/file2

if you cp the same file in the same folder to that folder, you can rename it, which duplicates the file. The only special command is to copy a directory, you need the -r option.

mv.

Move is a little more interest because it is basically renaming the absolute path of a file or directory. Unlike windows or other OS, where a file is deleted and recreated, the file stays the same, but it's absolute path changes. To rename 'myfolder' to 'thefolder' do this:

mv myfolder thefolder

To move myfolder into the folder

mv myfolder/ thefolder/

Move, unlike rm or cp, you don't need the -r flag to work with directories.

Remove – rm

The other basic task.

Unlike recycle bin, it's gone baby with rm. Salvaging deleted (rm-ed) files requires special software and is not easy; best to avoid this) Some nifty flags:

-f – delete it without y/n question verification.

-r – deletes an entire folder (and all its contents) – requried to delete a folder.

to delete all files in a directory (but keep the directory) this is a nifty trick.

rm -f * (wildcard for everything!)

WildCards and Spaces

· everything after that

? that specific characteristics

“ “ -- exactly as is, can include spaces.

\ -- escape character. so you can type spaces when that precedes the space . For example consider the file my file that you want to delete. A lot of choices when working with those funky file names, but ti's best just to name_files_like_this_with_the_underscore so you don't have to go into that crazy *?*\ !

You can delete it using the four methods above:

rm my*file or rm my* (assuming nothing else begins with my that you don't want to delete!)

rm my?file

rm “my file”

rm my\ file

Make Directory – mkdir

Very obvious and basic but one nifty “thinking ahead task”

-p – makes a new folder within a new folder

So if you're in an empty folder and type

mkdir myfolder/stuff/

you'll get an error sayin “myfolder” doesn't exist, but with:

mkdir -p myfolder/stuff/

then you'll create those two folders, “myfolder”, and “stuff”, within “myfolder”.

Links

There are two types of links, symbolic and hard. Symbolic links are created with

ln -s oldfile linktooldfile

Under ls -l it then points to the old file:

linktooldfile -> oldfile

note you have to throw in the -s (or –symbolic) option, or else it will automatically create hard links. Linux is so short and nifty with the options, instead of typing out –symbolic, just type -s!

Hard links actual change the file pointer and the only difference is that it will up the number before the owner under the file information

Mounting files

When you mount a drive, a symbolic link is created drawing from the /dev folder and the the /etc/fstab (file system table) file when the mount.

mount /media/cdrom

will look up the cdrom drlive in fstab and compare it to /dev based on a uuid number,to then mount it.

Manual Mount

Step 1: create a mount point (just a directory in /media/, although the mount point could be anywhere, it's best to stay organized and ue the /media directory) to mount the external drive to.

Step 2: check the partition type with

sudo fdisk -l /dev/hdb (warning: fdisk formats hard drives! be careful with it!)

step 3: now mount the disk (this is temporary mount and /newdisk will show up in the /mnt/ directory):

sudo mount -t nfts -o umask=0222 /dev/hdb1 /media/newdisk

Okay -t refers to type (ntfs, fat32 (vfat), ext3, etc.) then -o tells it you're doing more options, then /dev/hdb1 is the virtual device location and /media/newdisk is the mount point. After that command, the file should end up in /mnt/newdisk.

To unmount the drive, just type

umount /media/newdisk (also you could specify it's location in /dev/, but that's tricky and more complicated).

So in conclusion, mounting gets information from /etc/fstab, has a mount point in /media/, shows up after mounted in /mnt/, and accesses /dev wit uuid numbers to mount it = 4 seperate directories!

File Sizes

ls -h lists file sizes in kilobytes

ls -S lists file sizes with largest to smallest

ls -Shl shows all that information.

disk usage

du shows the directory size

du -h directory size in kilobytes.

du -sh total directory size in kilobytes.

(note du and find and the like are limited by permissions, so use sudo before it).

disk free space

df -h lists free disk space in kilobytes.

df shows ALL total mounted file systems! External, var, etc. to see your root, just look under the "mounted on" column.

No comments:

Mailing List



Validate%20Your%20Life
Quantcast