Epoxsea Software Document Help

Basic_Linux_Command

\#linux

Basic

Command

Description

Example

id

see the identity of your current account, and the your group memberships

id

groups

To list the names of the groups that you have memberships

groups

man

Display the manual page for a particular command

man <command>

clear

Clear the terminal screen

clear

history

View previous commands

history

alias

View aliases / Create alias

alias


alias <name>=<command>

pwd

Print current directory absolute path

pwd

ls

List files in specified directory (current directory by default)

ls


ls -al

cd

Change your current directory location

cd <dir>


cd ..

Quoting

Quoting

Description

'...'

Treat as normal string

"..."

Treat as formatted string, available variable substitution

`...`

Run command within ``

Operator

Operator

Description

Example

#

Comment

# comment

$/${}

Environment variable

$PATH/${PATH}

$()

Run command within the bracket

echo "current working dir: $(pwd)"

Misc.

  • Changes like setting variables, aliases are temporary

  • To make permanent, place command in ~/.bashrc file

File Manipulation

Command

Description

Example

touch

Create a file

touch <file>

cp

Copy a file

cp <file> <new file>


cp -r <dir> <new dir>

mv

Move a file

mv <file> <new loc>


mv -r <dir> <new dir>

rm

Delete a file

rm <file>


rm -r <dir>

mkdir

Make a new subdirectory

mkdir <dir>

chgrp

change the group owner of a file the user owns

chown

change user ownership of a file (only be used by the root user)

chmod

Change permission

chmod <permission> <file>

umask

determine the default permissions that are set when a new file or directory is created

Common Option

  • -v to display copy process

  • -i to prompt overwrites

  • -n to avoid overwrites

  • -r to copy directory structures

see more in: Linux File Ownership and Permission

Find Location

Command

Description

Example

which

Find all execute location

which <command>

whereis

Find execute / binary / source file location

whereis <command>

locate

Find any file as long as the user has permission to access

locate <command>

updatedb

Immediately update the locate database (normally by root user)

updatedb <command>

find

Search file

find / -type d

Command

Description

Example

read

Read user input

read <var name>


read -p "message" <var name>

echo

Output the string or value of a variable

echo <string>

strings

Output the strings in a file

strings <file>

cat

Output the content of a file

cat <file>

head

Output first 10 line of a file

head <file>

tail

Output first 10 line of a file

tail <file>

more

less

View file

less <dir>

file

Output description of a file

file <file>

test

expr

evaluates an expression and outputs the corresponding value

sort

uniq

newgrp

grep

Search text

grep <string> <file>


grep -E <regex> <file>

tr

sed

wc

Word count

wc -l <file>

cut

Cut

cut -d <char> -f1

Absolute Path

  • When you specify the location of a file or directory from the top level directory (called the root directory) through all of the sub directories to the file or directory.

  • Absolute paths start with /.

Relative Path

  • When you specify the location of a file or directory relative to the current directory.

  • Relative paths do not start with /.

Last modified: 12 June 2025