Linux Cheat Sheet

Published: 1/12/2009
 

A small Linux cheat sheet, introducing the very basic and very essential commands for surviving at the Linux CLI.

Moving around in the file system

Command

Action

pwd

"Print working directory" - show what dir you're in.

ls

List the contents of a dir.

ls -l

List the contents of a dir and show additional info of the files.

ls -a

List all files, including hidden files.

cd

Change directory.

cd ..

Go to the parent directory.

Examining files

Command

Action

file

Determine the type of a file.

cat

Concatenate a file.

less

View text files and paginate them if needed.

Manipulating files and directories

Command

Action

cp

Copy a file.

cp -i

Copy a file and ask before overwriting.

cp -r

Copy a directory with its contents.

mv

Move or rename a file.

mv -i

Move or rename a file and ask before overwriting.

rm

Remove a file.

rm -r

Remove a directory with its contents.

rm -i

Ask before removing a file. Good to use with the -r option.

mkdir

Make a directory.

rmdir

Remove an empty directory.

User management

useradd

Add a user. Must supply the username as an argument.

Groupadd

Adds a group. Must supply  the group name as an argument

usermod

Modifies a current user

Userdel

Removes a current user

Passwd

Sets the password. Must supply the user as an argument

Help

Man

Opens the help file. The command in question is the argument

File Permissions

ls -l

List details about the given folder tree

chmod

Changes the permission of the filename

chmod u+x filename

chmod g+rw filename

chmod g-w filename

chown

Changes the owner

chgrp

Changes the group

 

This list will be extended every session. Make sure you have the up-to-date version.

 

Related Posts

Linux File Structure Part 2

Last Updated: 1/12/2009 When you wish to use the CDROM drive it must first have a cdrom in the drive and data on the cdrom. To view the data you must mount the device to a given place of the Linux filing tree. Everything in Linux is a file. The whole partition of a hard dr
Read more...

 

Linux File Structure

Last Updated: 1/12/2009 Understanding the basic idea behind the Linux file structure can help but only if other people follow this idea!
Read more...

 

Pipe and Redirection

Last Updated: 1/12/2009 The command line is not only a tool for bashing out program names but an elegant and intelligent environment. Some programming languages can be typed directly into the command line. Also tasks that take some time to execute in the background leaving
Read more...

 

Beginners Guide to Vi

Last Updated: 1/12/2009 Beginners Guide to Vi
Read more...

 

Mounting a Drive

Last Updated: 1/12/2009 In Linux, like in UNIX, diskettes and CD-ROMs need to be mounted before they can be used. What mount does is to associate the devices (floppy or CD-ROM drives) to a mount point (a directory) in the root file system. The usual mount point for diskette
Read more...