Linux Index: Fisiere OS Legenda OS Script OS Log OS Emacs Retea Retete logShellScripting utileLinux Operare sistem - apropos = searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output. - cd = change directory - chmod = change file access permissions - cp = copy files and folders - df = tell you how much space their is on each partition - du = tell you how much space each directory is taking up - echo = display a line of text - fdisk = Partition table manipulator for Linux - find = search for files in a directory hierarchy - grep = print lines matching a pattern - history = History library, a programming tool that provides a consistent user interface for recalling lines of previously typed input - id = print user identity - ifconfig = configure a network interface - ln = make links between files; Op: -s = make symbolic links instead of hard links; Ex: ln -s filename filelink - ls = list directory contents - lspci = a utility for displaying information about all PCI buses in the system and all devices connected to them - mkdir = make directories - mkfs = build a Linux file system - mount = mount a file system - mv = move (rename) files - paswd = update a user authentication tokens - ps = gives a snapshot of the current processes - pwd = print name of current/working directory - quota = display disk usage and limits - rm = remove files or directories - scp = remote copy files - script = record your entire interactive login session. Ex: script -a scriptfile ; To exit type: 'exit' - sort = sort the output of a command or file in a specific order - sftp = secure file transfer program - su = switch user; Syntax: su - accountname; - to use the account's user environment - uname = print system information - umount = unmount file systems - wc = print the number of newlines, words, and bytes in files - whereis = locate the binary, source, and manual page files for a command - who = show who is logged on - xset = user preference utility for X; Ex: xset b off = turn off the pc speaker Editare,Vizualiare: - pico = is a simple, display-oriented text editor based on the Pine message system composer - less = vizualizare fisiere; "/" pt a gasii cuvinte cheie - more = vizualizare fisiere Arhivare: - bzip2/bunzip2 = comprima / decomprima fisiere *.bz2 - tar = comprima/decomprima fisiere tar Optiuni: -x = extract; v = verbose mode; c=create; z = use zip/gzip to compress the tar file or to read from a compressed tar file f = specifies the filename (which follows the f) Exemple: tar cvzf arhiva.tgz *.cc = arhiveaza toate fisierele *.cc din directorul curent tar xvf arhiva.tgz = dezarhiveaza toate fisierele - file-roller = aplicatie X pt crearea de arhive de toate tipurile - zip = creaza arhive zip - zipsplit = imparte in mai multe zipuri, un fisier mare zip; nu merge pt fisiere zip f mare (de ordinul sutelor de mega). Optiuni: -n [size] = maximum zip file size in bytes; -t = tell how many files would be used, but don't create them. Ex: zipsplit -tn 100000 blah.zip = spune in cate fisiere o sa fie impartita arhiva blash.zip - rar = creaza arhive rar Aplicatii GNOME: - nautilus = echivalentul lui windows explorer; Ex: nautilus --no-desktop --browser = deschide aplicatia in stilul browser - acroread = lanseaza acrobat reader - ooffice = lanseaza "word"-ul - kedit = GNOME text editor ------------------------------------------------------------------------------------ - cd = change directory SYNOPSIS cd [-L|-P] [dir] DESCRIPTION Change the current directory to dir. The variable HOME is the default dir. EXEMPLE - cd .. = Used to go back one directory - cd ~ = go to home directory - the same as 'cd' - cd / = go to / directory - cd /mnt/down32/ = go to 'down32' directory - cd - = switch between the current directory and the last directory ----------------------------------------------------------------------------------- - chmod = change file access permissions SYNOPSIS chmod [a/o/g/u][+/-][r/w/x] OPTIONS - a = all - o = others - g = groups - u = user - r = read permiss - w = write - x = execute Permission Legend(symbolic mode): -rwxrwxrwx. Primul caracter = fisier (-) sau dir (d), urmatoarele 3 = owner permiss, urmatoarele 3 = group permiss si ultimile 3 = overrall (network) permiss EXEMPLE - chmod a+w learnLinux/ = dir learnLinux poate fi scris de toti The second way to modify permissions with the chmod command is to use a number to specify each set of permissions for the file. 0 No permission --- 1 Execute permission ---x 2 Write permission -w- 3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx 4 Read permission r-- 5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x 6 Read and write permission: 4 (read) + 2 (write) = 6 rw- 7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx Exemplu: - chmod 775 filetest -> -rwxrwxr-x ----------------------------------------------------------------------------------- - cp = copy files and directories OPTIONS -r = copiaza recursiv directoare -i = Prompt whether to overwrite existing regular destination files (i = interactive) -v = Print the name of each file before copying it -u (--update) = Overwrites old files or copies missing files EXEMPLE - cp -r /home/daniel/dirSursa/ mnt/flash/dirDestinatie/ = copiaza continutului unui director in alt director ------------------------------------------------------------------------------------ - echo = display a line of text SYNOPSIS echo [OPTION]... [STRING]... DESCRIPTION Echo the STRING(s) to standard output. EXEMPLE - echo $PATH = pt. a afla variabila PATH a user-ului - echo $SHELL = pt. a afla versiunea de shell folosita ------------------------------------------------------------------------------------ - fdisk = Partition table manipulator for Linux SYNOPSIS fdisk [-u] [-b sectorsize] [-C cyls] [-H heads] [-S sects] device fdisk -l [-u] [device ...] fdisk -s partition ... fdisk -v DESCRIPTION Hard disks can be divided into one or more logical disks called partitions. This division is described in the partition table found in sector 0 of the disk. Linux needs at least one partition, namely for its root file system. It can use swap files and/or swap partitions, but the latter are more efficient. On Intel compatible hardware, the BIOS that boots the system can often only access the first 1024 cylinders of the disk. For this reason people with large disks often create a third partition, just a few MB large, typically mounted on /boot, to store the kernel image and a few auxiliary files needed at boot time, so as to make sure that this stuff is accessible to the BIOS. - fdisk (in the first form of invocation) is a menu driven program for creation and manipulation of partition tables. fdisk doesn’t understand GUID Partition Table (GPT) and it is not designed for large partitions. In particular case use more advanced GNU parted(8). The device is usually one of the following: /dev/hda /dev/hdb /dev/sda(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks, /dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks). A device name refers to the entire disk. The partition is a device name followed by a partition number. For example, /dev/hda1 is the first partition on the first IDE hard disk in the system. Disks can have up to 15 partitions. OPTIONS -l = List the partition tables for the specified devices and then exit. EXEMPLE - /sbin/fdisk -l - /sbin/fdisk /dev/hda = listeaza in mod interactiv partitiile de pe hard-disk-ul hda ------------------------------------------------------------------------------------ - find = search for files in a directory hierarchy SYNOPSIS find [-H] [-L] [-P] [path...] [expression] DESCRIPTION find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence, until the outcome is known, at which point find moves on to the next file name. OPTIONS - name = search for the file name - size = search for the file size EXEMPLE find /mnt/windows/WINDOWS/ -name encrypter.ocx = cauta fisierul 'encrypter.ocx' in path-ul ../WINDOWS/ find /mnt/vfat -size +100000k = cauta fisiere in /vfat mai mari decat 100000k ------------------------------------------------------------------------------------ - grep = print lines matching a pattern SYNOPSIS grep [options] PATTERN [FILE...] grep [options] [-e PATTERN | -f FILE] [FILE...] DESCRIPTION Grep searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines. OPTIONS -i = Ignore case distinctions in both the PATTERN and the input files -n = Prefix each line of output with the line number within its input file -r = Read all files under each directory, recursively EXEMPLE less runPAnalyzer.cfg | grep -n aberatie.root = cauta in output-ul comenzii precedente patternul "aberatie.root" si printeaza toata linia + nr liniei grep -rin learn* /home/daniel/Site/* = cauta in mod recursiv toate fisierele din Site/, cuvinte learn* ------------------------------------------------------------------------------------ - history History library, a programming tool that provides a consistent user interface for recalling lines of previously typed input After using the history command to see the list of recently run commands, you can repeat any of them simply by entering an exclamation point followed by the number of the command in question. Ex: [you@workstation20 ~]$ !84 Exemplu: - history > inFile ; less inFile ------------------------------------------------------------------------------------ - mkfs = build a Linux file system SYNOPSIS: mkfs [ -V ] [ -t fstype ] [ fs-options ] filesys [ blocks ] DESCRIPTION: mkfs is used to build a Linux file system on a device, usually a hard disk partition. filesys is either the device name (e.g. /dev/hda1, /dev/sdb2) or the mount point (e.g. /, /usr, /home) for the file system. blocks is the number of blocks to be used for the file system. OPTIONS: -t fstype = Specifies the type of file system to be built. If not specified, the default file system type (currently ext2) is used. Exemple: - mkfs -t ext2 /dev/hda4 = creaza o partitie de tip ext2 pt partitia /dev/hda4 ------------------------------------------------------------------------------------ - ls = list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). OPTIONS -a = do not ignore entries starting with . -l = list permisions, directories,groups, size, data, location -g = like -l, but do not list owner -h = human-readable -i = show the inode number */ = list the contests of all subdir -d */ = list only the directories -h = human-readable -X = sort alphabetically by entry extension -t = sort by modification time -S = sort by file size -r = reverse order while sorting --color[=WHEN] = control whether color is used to distinguish file types. WHEN may be ‘never’, ‘a and 'auto' . The environment variable LS_COLORS can influence the colors, and can be set by the dircolors command. The global configuration file is located at /etc/DIR_COLORS. The settings in this file can be overwridden by creating a file called .dir_colors in the user's home directory. Create a copy of /etc/DIR_COLORS at $HOME/.dir_colors and change the line of interest. ------------------------------------------------------------------------------------ - mount = mount a file system SYNOPSIS: mount [-lhV] mount -a [-fFnrsvw] [-t vfstype] [-O optlist] mount [-fnrsvw] [-o options [,...]] device | dir mount [-fnrsvw] [-t vfstype] [-o options] device dir Description: The standard form of the mount command, is mount -t type device dir. This tells the kernel to attach the file system found on device (which is of type type) at the directory dir. OPTIONS: -o = Options are specified with a -o flag followed by a comma separated string of options. Options: remount = Attempt to remount an already-mounted file system.This is commonly used to change the mount flags for a file system, especially to make a readonly file system writeable. It does not change device or mount point. rw = Mount the file system read-write. ro = Mount the file system read-only. -t vfstype = The argument following the -t is used to indicate the file system type. -t cifs = mount using the Common Internet File System (CIFS). The CIFS protocol is the successor to the SMB protocol and is supported by most Windows servers Exemple: - mount -o ro -t iso9660 /dev/cdrom /mnt/cdrom/ - mount -t ext2 /dev/hda4 /mnt/test/ = incarca sistemul de fisiere de tip ext2 de pe /dev/hda4/ in dir test - mount -o remount,rw /dev/VolGroup00/LogVol00 = remounts an already-mounted file system in read/write mode (rw) - mount /dev/fd0 /mnt/floppy = mount o discheta - mount -t vfat /dev/sda /mnt/flash = mount a memory stick - mount -t cifs //10.10.10.152/Filme /mnt/laptop = mount a XP share director (fat32 filesystem) over the net - mount -t vfat -o uid=daniel,umask=017 /dev/hda5 /mnt/vfat = mount a vfat local partition which can be access be user daniel - mount -t ntfs-3g /dev/hda1 /mnt/temp = mount a ntfs partition ------------------------------------------------------------------------------------ - mv = move (rename) files SYNOPSIS mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY ------------------------------------------------------------------------------------ - pico = simple text editor in the style of the Pine Composer The editor has five basic features: paragraph justification, searching, block cut/paste, a spelling checker, and a file browser. ctrl-^ = to mark test ctrl-w = to search word ctrl-k = to cut text ctrl-u = uncut text ----------------------------------------------------------------------------------- - ps = gives a snapshot of the current processes Gives a snapshot of the current processes. ps alone would list the current running processes. One can see the PID(process identifier). You can kill a process by typing "kill -9" and the PID number right afterwards. "-9" will ensure "execution" EXEMPLE - ps ux = display all processes owned by the current user - ps auwx | grep cron = display all processes which contains cron ----------------------------------------------------------------------------------- - rm = remove files or directories OPTIONS -r = sterge recursiv directoare -f = remove interactive mod ----------------------------------------------------------------------------------- - scp = remote copy files OPTIONS -l size(KB) = limiteaza rata de transfer EXEMPLE - scp file.pdf tonoiu@lxplus.cern.ch:dir1/dir2 ----------------------------------------------------------------------------------- - sftp = secure file transfer program SYNOPSIS sftp [[user@]host[:dir[/]]] DESCRIPTION sftp is an interactive file transfer program, similar to ftp, which performs all operations over an encrypted ssh transport. INTERACTIVE COMMANDS pwd = Display remote working directory lpwd = Print local working directory cd path = Change remote directory to 'path' lcd path = Change local directory to 'path' mkdir path = Create remote directory rmdir path = Remove remote director rm path = Delete remote file !command = Execute 'command' in local shell ! = Escape to local shell; return to sftp with 'exit' get remote-path [local-path] = Download file put local-path [remote-path] = Upload file EXEMPLE - sftp hostname@venus.nipne.ro ----------------------------------------------------------------------------------- - umount = unmount file systems SYNOPSIS umount [-hV] umount -a [-dflnrv] [-t vfstype] [-O options] umount [-dflnrv] dir | device [...] DESCRIPTION The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory. Note that a file system cannot be unmounted when it is ‘busy’ - example, when there are open files on it, or when some process has its working directory there, or when a swap file on it is in use. The offending process could even be umount itself - it opens libc, and libc in its turn may open for example locale files. A lazy unmount avoids this problem. EXEMPLE - umount /mnt/test/ = unmount sistemul de fisiere din directorul /mnt/test - umount -t vfat /dev/sda = umount a memory stick - umount -t iso9660 /dev/cdrom = umount a cd-rom, dvd-rom ----------------------------------------------------------------------------------- - rar Usage: rar <command> -<switch 1> -<switch N> <archive> <files...> <@listfiles...> <path_to_extract\> <Commands>: - a Add files to archive - e Extract files to current directory - v[t,b] Verbosely list archive [technical,bare] - x Extract files with full path <Switches>: - v<size>[k,b] Create volumes with size=<size>*1000 [*1024, *1] - m<0..5> Set compression level (0-store...3-default...5-maximal) Exemplu: rar a -v1000k -m0 test.rar fisier.avi = arhivezeaza "fisier.avi" in bucati de cate 1M, folosind nivelul de compresie store