Linux Commands
Linux Commands
ls -a hidden
cp Copy a file.
The cp command normally copies a file:
cp myfile anotherfile
cp myfile myfile2 myfile3 mydir
rm deleteme deleteme2
or recursively delete directories:
rm -r dir1 dir2
List
Directory Operations
File Viewing
File Properties
cut
The cut command extracts columns of text from files. A “column”
is defined by character offsets (e.g., the nineteenth character of
each line):
cat data.csv
one,two,three,four,five,six,seven
ONE,TWO,THREE,FOUR,FIVE,SIX,SEVEN
1,2,3,4,5,6,7
tar
The tar program packs many files and directories into a single
file for easy transport, optionally compressed. (It was originally
for backing up files onto a tape drive; its name is short for “tape
archive.”) Tar files are the most common file-packaging format
for Linux.
→ ls -lG myarchive.tar.gz
-rw-r--r-- 1 amit 350 Jun 20 12:49 cyberfrat.tar.gz
...
→ tar -xf cyberfrat.tar.gz (to Extract)
Zip
Zip [options] [files]
zip and unzip compress and uncompress files in Windows Zip
format. Compressed files have the extension .zip. Unlike most
other Linux compression commands, zip does not delete the
original files.
A process is a unit of work on a Linux system. Each program you run represents one or more
processes, and Linux provides commands for viewing and manipulating them. Every process
is identified by a numeric process ID, or PID.
ps - List process.
Controlling Processes
pidof apache2
iimeout -
The timeout command sets a time limit for running another timeout Kill a command that runs for
too long.program, in seconds.
sleep 60
timeout 3 sleep 60
As a more practical example, play music from your MP3 collection for an hour, then stop:
→ timeout 3600 mplayer *.mp3
Scheduling Jobs
crontab
logname
The logname command prints your login name (it might
seem trivial, but it’s useful in shell scripts):
The whoami command prints the name of the current, effective user.
deluser balaji
Useful options
-d dir Change the user’s home directory to dir.
-l username Change the user’s login name to username.
-s shell Change the user’s login shell to shell.
-g group Change the user’s initial (default) group to
Group, which can either be a numeric group ID or
a group name, and which must already exist.
-L Disable a user
-U Unlock the user
chfn -
Group Management
Host Information
uname Print basic system information.
ifconfig wlp1s0
Host Location
ping google.com
wget - The wget command hits a URL and downloads the data to a file
or standard output. It’s great for capturing individual web
pages, downloading files,
Installing Softwares