info:basic_commands
This is an old revision of the document!
Table of Contents
Basic commands for working with Linux
This section covers some very basic commands to efficiently work with a Linux system. They should be available on all standard installations. Although many modern Linux variants offer an advanced GUI, it is advisable to be able to control a Linux system from command line.
Working with Files
lslists files in current directory. Usels -alto list all files (including hidden = starting with .) in a long listing.mkdircreates a directory. Specify the directory name after the command.rmremoves files and directories. If directories need to be removed, the-roption must be specified. To force operation, add-f. The last parameters are the files and directories that are to be deleted. Make sure that there are no wrong directories listed! A call torm -rf /as root is not a good thing.mvmoves a file, where path is relative to current directory: mv [path]filename [path]filnamefilereveals what content type a file is. Use it to test if a file is text, image, binary or whatever.findandrmcan be used in combination to delete files found byfind. e.g. this will recursively remove all files with extension.txtin the current directory:find . -name \*.txt -print0 | xargs -0 rm
As an alternative, it is possible to use some shell features:rm $(find -name \*.txt)sudostarts a process with super user (=root) capabilities. To start a root shell, usesudo su. Ifsudois not installed, usesuinstead. It requires not the current user's password but the root password.lesshelps to look at what a file stores.catreads a file and prints it tostdout(the console if invoked as-is.)locatelocates all files that contain a given string.grepsearches input for matching lines. To search all files in the current directory (and sub directories), usegrep -r . -e “text”.manshows the manual for some command. Sometimesinfoshows a more detailed documentation.dmesgprints kernel messages.
Networking Tools
HTTP/FTP
- Use
wgetto download files from HTTP and FTP. The tool allows recursive downloading, i.e. also fetch outgoing links from some HTML page. To restrict the files downloaded to a certain type (by file suffix), use the-Aoption:wget -r http://some.host/path/to/file.html -A pdf
downloads all PDF's referenced by the HTML file.
Piping
The output of one command can be piped into the input of another command. This is done by the pipe operator |. To search kernel messages for some string, use dmesg | grep string.
Additionally, the STDOUT (1) and STDERR (2) streams can also be redirected. To redirect the STDERR output to STDOUT, use: command 2>&1 …. This can be used in combination with piping.
info/basic_commands.1260447457.txt.gz · Last modified: (external edit)
