Linux command line

Ace your homework & exams now with Quizwiz!

pattern

* All files g* Any file beginning with "g" b*.txt Any file beginning with "b" followed by any characters and ending with ".txt" Data??? Any file beginning with "Data" followed by exactly three characters [abc]* Any file beginning with either an "a", a "b", or a "c" BACKUP.[0-9][0-9][0-9] Any file beginning with "BACKUP." followed by exactly three numerals [[:upper:]]* Any file beginning with an uppercase letter [![:digit:]]* Any file not beginning with a numeral *[[:lower:]123] Any file ending with a lowercase letter or the numerals "1", "2", or "3"

Symbols & file types

* Executable / Directory @ Symbolic link : work like window shortcuts | FIFO (AKA a named pipe) = Socket

how to copy and paste

If you are using a mouse, you can double click on a filename to copy it and middle click to paste it into commands.

cd

change directory cd ~ change to home directory cd - takes you back to prev directory cd .. back period before a path / can jump in any directory that specified in the home folder. ex: cd ./bin takes you to /usr/bin without having to type the full directory.

soft link

creates a file that holds a pointer to the original file's pathname.

file

file file-name print brief description of the file's content.

df

show disk usage

mv

-Move/rename files and directories -i --interactive Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv will silently overwrite files. -u --update When moving files from one directory to another, only move files that either don't exist, or are newer than the existing corresponding files, in the destination directory -v --verbose Display informative messages as the move is performed example: mv file1 file2 dir1 Move file1 and file2 into directory dir1. dir1 must already exist.

ls

-l shows file or directory, size, modified date and time, file or folder name and owner of file and its permission. -a view hidden files -lh list files with human readable format -F option with ls command, will add the '/' Character at the end each directory. -r option display files and directories in reverse order. -R list file that are recursive example: ls -r ~/iso this view the contents of several sub directories with one command that include iso. -ltr will shows latest modification file or directory date as last -ls list file by size, will display big first -i options list file / directory with inode number. --color display things in color -l /directory/ list directory information -d list date -n list UID and GID of files and directories ls ~ /usr list home directory and /usr directory

Directory

/ The root directory. Where everything begins. /bin Contains binaries (programs) that must be present for the system to boot and run. /boot Contains the Linux kernel, initial RAM disk image (for drivers needed at boot time), and the boot loader. Interesting files: ● /boot/grub/grub.conf or menu.lst, which are used to configure the boot loader. ● /boot/vmlinuz, the linux kernel /dev This is a special directory which contains device nodes. "Everything is a file" also applies to devices. Here is where the kernel maintains a list of all the devices it understands. /etc The /etc directory contains all of the system-wide configuration files. It also contains a collection of shell scripts which start each of the system services at boot time. Everything in this directory should be readable text. Interesting files: While everything in /etc is interesting,here are some of my all-time favorites: ● /etc/crontab, a file that defines when automated jobs will run. ● /etc/fstab, a table of storage devices and their associated mount points. ● /etc/passwd, a list of the user accounts. /lib Contains shared library files used by the core system programs. These are similar to DLLs in Windows. /lost+found Each formatted partition or device using a Linux file system,such as ext3, will have this directory. It is used in the case of a partial recovery from a file system corruption event.Unless something really bad has happened to your system, this directory will remain empty. /media mount points for USB ( new linux ) /mnt same but for old linux version /opt install optional software, hold commercial software /proc The /proc directory is special. It's not a real file system in the sense of files stored on your hard drive. Rather, it is a virtual file system maintained by the Linux kernel. The "files" it contains are peepholes into the kernel itself. The files are readable and will give you a picture of how the kernel sees your computer.

Directory (continued)

/sbin This directory contains "system" binaries. These are programs that perform vital system tasks that are generally reserved for the superuser. /tmp The /tmp directory is intended for storage of temporary, transient files created by various programs. Some configurations cause this directory to be emptied each time the system is rebooted. /usr The /usr directory tree is likely the largest one on a Linux system. It contains all the programs and support files used by regular users. /usr/bin /usr/bin contains the executable programs installed by your Linux distribution. It is not uncommon for this directory to hold thousands of programs. /usr/lib The shared libraries for the programs in /usr/bin. /usr/local The /usr/local tree is where programs that are not included with your distribution but are intended for system- wide use are installed. Programs compiled from source codeare normally installed in /usr/local/bin. On a newly installed Linux system, this tree exists, but it will be empty until the system administrator puts something in it. /usr/sbin Contains more system administration programs. /usr/share /usr/share contains all the shared data used by programs in /usr/bin. This includes things like default configuration files, icons, screen backgrounds, sound files,etc. /usr/share/doc Most packages installed on the system will include some kind of documentation. In /usr/share/doc, we will find documentation files organized by package. /var With the exception of /tmp and /home, the directories we have looked at so far remain relatively static, that is, their contents don't change. The /var directory tree is where data that is likely to change is stored. Various databases, spool files, user mail, etc. are located here. /var/log /var/log contains log files, records of various system activity. These are very important and should be monitored from time to time. The most useful one is /var/log/messages. Note that for security reasons on some systems, you must be the superuser to view log files .

Wildcard

Characters to find words or phrases that contain specific letters or combination of letters * Matches any characters ? Matches any single character [characters] Matches any character that is a member of the set characters [!characters] Matches any character that is not a member of the set characters [[:class:]] Matches any character that is a member of the specified class

ln

Create hard and symbolic links ls file link -create hard links ls -s file link -create symbolic links

mkdir

Creates a directory can be repeated ex- mkdir file1 file 2 file3 would create 3 directory

character class

List of values that can match a single character [:alnum:] Matches any alphanumeric character [:alpha:] Matches any alphabetic character [:digit:] Matches any numeral [:lower:] Matches any lowercase letter [:upper:] Matches any uppercase letter

hard links

Makes a copy of the original file with a new name, BUT can only be used by files in the same directory. 1. A hard link cannot reference a file outside its own file system. This means a link may not reference a file that is not on the same disk partition as the link itself. 2. A hard link may not reference a directory.

rm

Remove files and directories -i Before deleting an existing file, prompt the user for confirmation. If this option is not specified, rm will silently delete files. -r Recursively delete directories. This means that if a directory being deleted has sub directories, delete them too. To delete a directory, this option must be specified. Be particularly careful with wildcards. Consider this classic example. Let's say you want to delete just the HTML files in a directory. To do this, you type: rm *.html which is correct, but if you accidentally place a space between the "*" and the ".html" like so: rm * .html the rm command will delete all the files in the directory and then complain that there is no file called ".html". check the command with ls first before rm

-rw-r--r-- 1 root root

access right to the file, first character indicate file type, - is regular file and d is directory then next 3 is owners --> groups --> everyone else 1 is number of hard links root - user name of file owners root - name of group which owns the file l is soft link

alias

an assumed name alias pwd="pwd -P"

cp

copy files and directories cp Src_file1 Src_file2 Src_file3 Dest_directory (copy multiple file to dest) cp -R Src_directory Dest_directory( copies all file in the src to dest, create one if don't exist) -a, --archive Copy the files and directories and all of their attributes, including ownership and permissions. Normally,copies take on the default attributes of the user performing the copy . -i, --interactive Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files. -r, --recursive Recursively copy directories and their contents. This option (or the -a option) is required when copying directories -u, --update When copying files from one directory to another, only copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory -v, --verbose Display informative messages as the copy is performed.

free

display amount of free memory

pwd

print working directory , tell you where you are

less

view file instead of opening the file G move to end of file and g move to beginning of file /word search the word q quit


Related study sets

Anatomy lecture exam chapter 20 to 25

View Set

10th Grade Vocabulary - List #6 - Quiz: 11/7/23

View Set

Chapter 4 Work and Machines Sect 1 - What is Work?

View Set

28. Antbióticos betalactámicos e inhibidores.

View Set

35 Facts about President Barack Obama you may not know

View Set