<<

Commands: Short List for CTEC145

Folders/Directories

1. Hierarchical system Root /

bin dev etc home media root sbin tmp usr

Directories robert jenny jack

Bin notes

Files Report Log

2. touch file.25,qwerty #creates a file without content

3. #Lists names of directories and files a. > ls –a #includes hidden files b. > ls –l #shows details & permissions of files -rw-rw-r-- 1 chris sales 5555 Jan 11 11:20 file.25,qwerty c. > ls –al #all files in long form 1) drwxrwxrwx 2 root root 1024 Jan 12 13:55 . 2) drwxr-xr-x 3 root root 1024 Jan 10 01:49 .. 3) -rw-r--r-- 1 chris sales 1155 Jan 10 01:50 .Xdefaults 4) “.” pathname of the working directory. 5) “..”pathname of the parent directory 6) .Xdefaults is hidden because of the dot before the name 4. #change directory

> cd #Takes user to their own home directory > cd ~robert #Takes to home directory of robert > cd ~/Desktop #~ denotes complete to home directory cd .. #moves up one directory cd /etc #moves to the etc directory 5. Absolute/relative pathnames > cd /home/jsande/Desktop #absolute pathname > cd Desktop #relative pathname 6.

#creating a directory > mkdir sales > mkdir folder1 folder2 #can create several directories once 7. #removing a directory > rmdir sales 8. #removing a file rm > rm letter > rm –rf sales #will forcible remove a directory w/ contents Linux Commands: Short List for CTEC145

9. > pwd #gives path to current directory 10. man #System manual with pages on commands man > man 11. info # help pages on commands info > info who

12. Exiting > exit out of > -h now shutdown OS > shutdown -r now reboot OS Ctrl-c, Ctrl-d, q, may get you out of a program

Linux Commands: Short List for CTEC145

File Commands &

1. Filenames: case sensitive: memo5 ≠ MEMO5 ≠ Memo5 restrictions: do not use *, ?, >, <, / 2. cp #Copy a File cp > ls output > cp output outputb > ls output outputb > cp /etc/inittab /root > cp /etc/inittab . (copies to present ) 3. Simple word processor > cat > notes To shutdown computer: shutdown –h now. Ctrl+c View contents > cat notes #Displays content of a text file > cat –n inittab #-n option: numbers the lines 4. Opening vi vi 5. Edit/Insert Mode Command Action A Appends text after the current character I Inserts text before the current character O Inserts a blank line below the current line Exits edit/insert mode 6. Command Mode Command Action :w Writes to file :q Quits editor :wq Writes & quits :w! Forcefully writes to the specified file :q! Quits without saving Deletes a line U Undoes the last change made .(dot) Repeats the last change made Yy Yanks the current line, which is to be copied Nyy Yanks n lines, including the current line P Pastes the yanked text after the current line X Deletes character / Finds the next line containing the specified pattern :set nu Numbers each line Linux Commands: Short List for CTEC145

7. more #Scrolls down screen more 8. less #Scrolls down screen: more, less (can also scroll up) less > less /etc/inittab 9. Change Name of File mv > ls notes inittab > mv inittab > ls notes test a file to a new location: mv > mv test /home/robert > cd ~robert > ls 10. 4 setuid 2 setgid 1 sticky-bit # chmod 4511 file1 dr-s--x--x #Group & others can’t read but can execute as if root # chmod 2710 file1 drwx--s--- #Group can’t read but can execute as if root # chmod 1733 file1 drwx-wx-wt #Prohibits groups & others from changing name or deleting files in a directory 11. #Changes owner of file/directory chown # chown john file2 # ls –l file2 -rw-rw-r-- 1 john users 181 Mar 30 2026 file2 # chown mary:sales file2 #Changes owner and group name -rw-rw-r-- 1 mary sales 181 Mar 30 2026 file2 12. #Changes group of file/directory chgrp bill file2 -rw-rw-r-- 1 john bill 181 Mar 30 2026 file2