Linux Commands

  • To search file in terminal
    find /. -name filename\*
  • List the files in your current directory
    ls
  • Short cut to open terminal
    ctrl+alt+t(ubuntu)
  • command will allow you to know in which directory you're located
    pwd(pwd stands for "present working directory")
  • command to copy the file
    "cp file foo" will make an exact copy of "file" and name it "foo"
    "cp -r directory foo" (copy recursively). (To understand what "recursively" means, think of it this way: to copy the directory and all its files and subdirectories and all their files and subdirectories of the subdirectories and all their files, and on and on, "recursively")
  • command to move file from location to other location
    "mv file foo" will rename the file "file" to "foo"
  • command to remove file from directory
    "rm file"
  • command is used to show you the manual of other commands
    "man command"
  • command to run a file using the command-line
    ./filename.extension
  • command to edit text file
    vi filename
  • commands that you want to run on a regular schedule(run cmds to fixed time)
    crontab -e
    For more information
  • To get processid of process
    ps aux | grep processname
  • To kill process
    kill - 9 processid
  • To get ipaddress using url
    nslookup url(hostname)
  • To get size of disk
    du dirname
  • To create tar(zip) file
    tar -zcvf zipfilename.tar.gz filename(should be zip)
  • To create untar(un zip) file
    tar -xzvf filename.tar.gz
  • How to enable root user
    sudo passwd root
  • cmd to zip
    zip -r zipfilename filehastodozip
  • To get size of disk
    df -h
  • cmd to copy the file
    cp existingfile /newfile cp -p filename /path/to/new/location/myfile(To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter:)
  • cmd to know the process name using port number
    netstat -tulpn | grep :portnumber
  • cmd to get jar version in terminal
    java -jar jarname
  • cmd to check who are logged into the
    finger
  • Used to include manifest information from an existing manifest file
    jar cmf existing-manifest(path of manifest file) jar-file input-file(s)
  • Command to check if ACL is opened from one host to another host
    nc -z hostname portnumber
  • Command to check db information which is existing in filesystem
    tnsping filesystem
  • Command to replace a string in multiple files
    perl -pi -e 's/oldstring/newstring/g' *
  • Command to get only jar names which are present in directory
    ls -lrt| awk '{print $10}'|awk -F '.jar' '{print $1}'
  • command to get total size of all files
    ls -FaGl "${@}" | awk '{ total += $5; print }; END { print total }';
  • Compare two directories in linux
    diff -r directory1 directory2
  • To get os information
    uname -a

No comments:

Post a Comment