Skip to main content

Basic Commands for Dealing with Files and Directories

Here are some basic commands for creating and removing files and directories, changing and displaying the current directory, and displaying a tree diagram of a directory hierarchy. We will look at other commands in future topics.

DescriptionLinux CommandWindows CommandNotes
Make a Directorymkdir directorymkdir directory
Remove a Directory (Must be empty)rmdir directoryrmdir directory
Change (Working) Directorycd directorycd directory
Print Current Working Directorypwdcd
Change to Home Directorycd
List Contents of Directoryls
ls -l
dirLinux: -l option displays long listing (including permissions, ownership, size, modification date/time)
Create an Empty Filetouch filecopy nul file
Remove/Delete a Filerm filedel file
Display a Tree Diagram starting at Current Directorytreetree
tree /f
Windows: /f causes tree to display files (otherwise only directories
are shown)
Copy a filecp sourcefile destinationfilecopy sourcefile destinationfile
Move or rename a filemv currentfilename newfilenamemove currentfilename newfilename
Display the text contents of a filecat filetype fileNote: Using these commands on a file that contains non-text data may look very strange.