You are on page 1of 4

Linux Commands: Short List for CTEC145

Folders/Directories
1.

Hierarchical File system


Root
bin
Directories

/
dev
robert

etc

home

media

jenny

root

2.

Report

ls
a.
b.
c.

4.

5.

6.

7.
8.

usr

notes
Log

Touch
touch file.25,qwerty

3.

tmp

jack
Bin

Files

sbin

cd

#creates a file without content

#Lists names of directories and files


#includes hidden files
#shows details & permissions of files
-rw-rw-r-- 1 chris sales 5555 Jan 11 11:20 file.25,qwerty
> 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
#change directory

> ls a
> ls l

> cd
#Takes user to their own home directory
> cd ~robert
#Takes to home directory of robert
> cd ~/Desktop
#~ denotes complete path to home directory
cd ..
#moves up one directory
cd /etc
#moves to the etc directory
Absolute/relative pathnames
> cd /home/jsande/Desktop
#absolute pathname
> cd Desktop
#relative pathname
mkdir <dir name>
#creating a directory
> mkdir sales
> mkdir folder1 folder2
#can create several directories at once
rmdir
#removing a directory
> rmdir sales
rm
#removing a file
rm <filename>
> rm letter
> rm rf sales
#will forcible remove a directory w/ contents

Linux Commands: Short List for CTEC145


9.

pwd
> pwd

10. man

#gives path to current directory


#System manual with help pages on commands

man <command>
> man who
11. info

#More help pages on commands


info <command>
> info who

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

Linux Commands: Short List for CTEC145


File Commands & vi
1.

2.

3.

4.
5.

6.

Filenames:
case sensitive: memo5 MEMO5 Memo5
restrictions: do not use *, ?, >, <, /
cp
#Copy a File
cp <source-file> <destination-file>
> ls
output
> cp output outputb
> ls
output outputb
> cp /etc/inittab /root
> cp /etc/inittab . (copies to present dir)
cat
Simple word processor
> cat > notes
To shutdown computer: shutdown h now. <enter>
Ctrl+c
View contents
> cat notes
#Displays content of a text file
> cat n inittab
#-n option: numbers the lines
Opening vi
vi <filename>
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
<Esc>
Exits edit/insert mode
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
Dd
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
/<pattern>
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 <file name>

8.

less

#Scrolls down screen: more, less (can also scroll up)


less <file name>
> less /etc/inittab

9.

mv
Change Name of File
mv <existing-filename> <new-filename>
> ls
notes inittab
> mv inittab test
> ls
notes test
Move a file to a new location:
mv <filename> <path-to-new directory>
> mv test /home/robert
> cd ~robert
> ls

10.

chmod

11.

4
setuid
2
setgid
1
sticky-bit
# chmod 4511 file1
dr-s--x--x
#Group & others cant read but can execute as if root
# chmod 2710 file1
drwx--s--#Group cant 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
chown
#Changes owner of file/directory
chown <username> <filename>
# 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
chgrp
#Changes group of file/directory
chgrp bill file2
-rw-rw-r-- 1 john bill
181 Mar 30 2026 file2

12.

You might also like