sysadmin:linux:basic_commands
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sysadmin:linux:basic_commands [2025/12/16 02:39] – mlivolsi | sysadmin:linux:basic_commands [2025/12/16 03:09] (current) – mlivolsi | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| |more filename | shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit. You can use /pattern to search for a pattern. | | |more filename | shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit. You can use /pattern to search for a pattern. | | ||
| - | |head filename | show me the first lines of a file | | + | |head filename | show me the first lines of a file | |
| - | |tail filename | show me the last lines of a file | | + | |tail filename | show me the last lines of a file | |
| - | |vi filename | Another editor (preferred) | | + | |vi filename | Another editor (preferred) | |
| - | |mv filename1 filename2 | moves a file (i.e. gives it a different name, or moves it into a different directory (see below) (dos equivalent of rename) | + | |mv filename1 filename2 | moves a file (i.e. gives it a different name, or moves it into a different directory (see below) (dos equivalent of rename) |
| - | |cp filename1 | + | |cp filename1 filename2 | copies a file (dos equivalent of copy) | |
| - | |rm filename | removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything. You can make this your default by making an alias in your .cshrc file. (dos equivalent of erase) | + | |rm filename | removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything. You can make this your default by making an alias in your .cshrc file. (dos equivalent of erase) |
| - | |diff filename1 filename2 | compares files, and shows where they differ | | + | |diff filename1 filename2 | compares files, and shows where they differ | |
| |wc filename | |wc filename | ||
| - | |chmod options filename |lets you change the read, write, and execute permissions on your files. The default is that only you can look at them and change | + | |chmod options filename |lets you change the read, write, and execute permissions on your files. The default is that only you can look at them and change them, but you may sometimes want to change these permissions. For example, chmod o+r filename will make the file readable for everyone, and chmod o-r filename will make it unreadable for others again. Note that for someone to be able to actually look at the file the directories it is in need to be at least executable. See help protection for more details.| |
| |tar –cvf filename.tar | Make a non-compressed aggregate of files| | |tar –cvf filename.tar | Make a non-compressed aggregate of files| | ||
| |tar –xvf filename.tar | Extract files out (files are known as ‘tarballs’)| | |tar –xvf filename.tar | Extract files out (files are known as ‘tarballs’)| | ||
| - | File Compression | + | **File Compression** |
| - | gzip filename | + | | gzip filename |
| - | gunzip filename | + | | gunzip filename |
| - | + | | gzcat filename | |
| - | gzcat filename | + | |
| - | Directories | + | **Directories** |
| - | mkdir dirname | + | |
| - | cd dirname | + | | mkdir dirname |
| - | pwd --- tells you where you currently are. | + | | cd dirname |
| - | Finding things | + | | pwd | tells you where you currently are.| |
| + | |||
| + | **Finding things** | ||
| - | find --- find files anywhere on the system. This can be extremely useful if you've forgotten in which directory you put a file, but do remember | + | |find |find files anywhere on the system. This can be extremely useful if you've forgotten in which directory you put a file, but do remember the name. (ie. find . –name foo.bar –print )| |
| - | + | |grep string filename(s) | |
| - | grep string filename(s) | + | |
| - | About other people | + | |
| - | w --- tells you who's logged in, and what they' | + | |
| - | who --- tells you who's logged on, and where they' | + | **About |
| - | finger username --- gives you lots of information about that user, e.g. when they last read their mail and whether they' | + | |
| - | last -1 username --- tells you when the user last logged | + | |w |tells you who' |
| - | About your (electronic) self | + | |who |tells you who's logged on, and where they' |
| - | whoami --- returns your username. Sounds useless, but isn't. You may need to find out who it is who forgot to log out somewhere, and make sure *you* have logged out. | + | |finger username | gives you lots of information about that user, e.g. when they last read their mail and whether they're logged |
| - | finger | + | |last -1 username | tells you when the user last logged on and off and from where. Without any options, last will give you a list of everyone's logins.| |
| - | of course | + | |
| - | passwd --- lets you change your password, which you should do regularly (at least once a year). See the LRB guide and/or look at help password. | + | |
| - | ps -u yourusername --- lists your processes. | + | |
| - | kill PID --- kills (ends) the processes with the ID you gave. This works only for your own processes, | + | |
| - | du filename --- shows the disk usage of the files and directories in filename (without argument the current directory is used). du -s gives only a total. | + | |
| - | df –k – Available space on all storage devices | + | |
| - | last yourusername | + | |
| - | Connecting to the outside world | + | |
| + | **About your (electronic) self** | ||
| - | ssh –l username hostname --- also lets you connect to a remote host. Use rlogin whenever | + | |whoami | returns your username. Sounds useless, but isn't. You may need to find out who it is who forgot to log out somewhere, and make sure *you* have logged out.| |
| - | + | |finger | of course you can finger yourself, too. That can be useful e.g. as a quick check whether you got new mail. Try to create a useful .plan file soon. Look at other people' | |
| - | sftp username@hostname | + | |passwd | lets you change your password, which you should do regularly (at least once a year). See the LRB guide and/or look at help password.| |
| - | + | |ps -u yourusername | lists your processes. | | |
| - | lynx --- lets you browse the web from an ordinary terminal. (not always available) | + | |kill PID | kills (ends) the processes with the ID you gave. This works only for your own processes, of course. Get the ID by using ps. If the process doesn' |
| - | Miscellaneous | + | |du filename | shows the disk usage of the files and directories in filename (without argument the current directory is used). du -s gives only a total.| |
| - | date --- shows the current date and time. | + | |df –k | Available space on all storage devices | |
| - | cal --- shows a calendar of the current month. Use e.g., 'cal 10 1995' to get that for October 95, or 'cal 1995' to get the whole year. | + | |last yourusername | lists your last logins. Can be a useful memory aid for when you were where, how long you've been working for, and keeping track of your phonebill if you're making a non-local phonecall for dialling in.| |
| - | bc – basic calculator (control-d to quit) | + | |
| - | man - (manual) get help on a topic | + | **Connecting to the outside world ** |
| - | top – show processes, memory and cpu (control –c to quit) | + | |
| - | uname –a – Name and operating system of the machine I’m on | + | |ssh –l username hostname | also lets you connect to a remote host. Use rlogin whenever possible.| |
| + | |sftp username@hostname | ||
| + | |lynx | lets you browse the web from an ordinary terminal. (not always available) | ||
| + | |||
| + | **Miscellaneous tools ** | ||
| + | |||
| + | |date | shows the current date and time.| | ||
| + | |cal | shows a calendar of the current month. Use e.g., 'cal 10 1995' to get that for October 95, or 'cal 1995' to get the whole year.| | ||
| + | |bc | ||
| + | |man | ||
| + | |top | ||
| + | |uname –a | Name and operating system of the machine I’m on | | ||
| You can find out more about these commands by looking up their manpages: | You can find out more about these commands by looking up their manpages: | ||
| - | man commandname --- shows you the manual page for the command | + | |
| + | man commandname --- shows you the manual page for the command | ||
sysadmin/linux/basic_commands.1765852791.txt.gz · Last modified: by mlivolsi
